/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ui;

import engine.goods.Goods;
import function.GameSet;
import function.Property;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;
import mainpackage.Constant;
import mainpackage.GameBean;
import mainpackage.InputInterFace;
import mainpackage.MainCanvas;
import mainpackage.MainGame;
import mainpackage.MainLogic;
import mainpackage.MainView;
import mainpackage.ResManager;
import mainpackage.Tools;

/**
 *
 * @author foonwayx
 */
public class UiPackage {

    private int iPositionY = 0; //用来记录选择线的位置
    public int[] iArray;
    public int iStartPointY;   //包裹栏开始的位置
    private Image[] imgArray;
    public String[] sArray; //界面上文字数组
    public boolean bKeypressLock = false; //键盘锁
    public boolean bShowMenu;  //显示弹出菜单
    public boolean bWaitMSGBack = false;  //从网络获得物品的简单描述，防止重复发送
    public byte bySelectIndex; //一级选中状态。从1开始
    public byte bySubSelectIndex; //子选择索引
    public byte byMenuIndex;//物品操作选项索引
    private byte byTotalPage = 1; //总的页数
    public byte byCurrentPage = 1;  //当前页数
    public byte byTabIndex;   //包裹栏和任务道具选择索引
    public Goods packageGoods; //普通道具
    public Goods taskPackageGoods; //任务物品栏
    public Goods petPackageGoods; // 宠物栏
    public Goods equipPackageGoods; // 装备栏
    public byte byUiState = 0; //界面UI状态
    public long lMoney = 0L; //钱数量（单位铜币）
    public long lastSendDescTime = 0L; //最后向网络请求物品描述的时间
    public String[] sOpArray = null; //被选中的物品的可操作的选项
    public byte byState;  //界面操作中记录小的状态
    private int iStartX;
    private int iStartY;
    public short shPos = 0;  //当前物品索引
    //显示通用的包裹栏的开关
    public static boolean bShowBAG = false;
    public static boolean bSendShowBag = false; //发送通用的打开背包的指令
    public static short shGetNetDescPos = -1; //记录动态获得物品描述的索引
    public static byte byGetNetDescTabIndex = -1;
    public static byte byPopUpState = 1;
    public short shHeight = 0;
    public String[] sEquipName = null;
    public String[] sEquipPlaceName = null;
    public boolean bSoldItems = false; //出售物品
    public int iGoodsDescHeight = 0; //描述的高度
    private boolean bMoveGoods = false;
    public short shMoveIndex = -1;
    public short shMoveDestIndex = -1;
    public short shMoveNum = 0;
    private boolean bShowNumInput = false;
    private boolean bShowFlash = false;
    private byte byPetGrowth = -1;
    private String sPetDetail = null;
    private boolean bUseBindSignItem = false;
    private byte byRecordTabIndex = -1;//记录曾经选过的物品栏索引
    private short shRecordItemIndex = -1;//记录曾经选过的物品索引
    public boolean[] bGetDataFromNet;//记录包裹栏是否已从网络上获得了数据
    public String sTips;
    public short shTipsW;
    public short shTipsH;
    public byte bySortItem = -1;

    public UiPackage() {
    }

    public void lockPackageItems(String itemKey) {
        if (this.getCurrentPackage() == null || itemKey == null) {
            return;
        }
        short max = this.getCurrentPackage().getMaxColumNum();
        for (byte i = 0; i < max; i++) {
            if (this.getCurrentPackage().sGoodsKey[i] != null && this.getCurrentPackage().sGoodsKey[i].equals(itemKey)) {
                this.shPos = i;
                this.byCurrentPage = (byte) Tools.ceil(this.shPos + 1, 28);
                this.bySelectIndex = (byte) ((this.shPos - (this.byCurrentPage - 1) * 28) / 7 + 2);
                this.byTotalPage = (byte) Tools.ceil(max, 28);
                setPackageState((byte) 0);
                break;
            }
        }
    }

    /**
     * 通用的包裹显示
     */
    public void showBag(byte bDefaultColumnType) {
        GameBean.b_WAIT_NET_MSG_BACK = true;
        this.bSendShowBag = true;
        GameBean.BY_TYPE = bDefaultColumnType;
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_BAG, Constant.SOCKET_MSG_TYPE_LOGIC);
    }

    /**
     * 打开包裹界面
     * @param bDefaultColumnType 
     */
    public void openBag(byte bDefaultColumnType) {
        GameBean.b_WAIT_NET_MSG_BACK = true;
        GameBean.BY_TYPE = bDefaultColumnType;
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_BAG, Constant.SOCKET_MSG_TYPE_LOGIC);
    }

    public void sortBagItems(byte bDefaultColumnType) {
        GameBean.b_WAIT_NET_MSG_BACK = true;
        GameBean.BY_TYPE = bDefaultColumnType;
        this.bySortItem = 1;
        MainLogic.getInstance().send(Constant.MSG_NET_CMD_SORT_ITEM, Constant.SOCKET_MSG_TYPE_LOGIC);
    }

    /****
     * 
     */
    public void setBagData(byte byColumnType, short shMaxColumnNum) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (byColumnType) {
            case Constant.ITEM_COLUMN_TYPE_COMMON:
                if (this.packageGoods == null) {
                    this.packageGoods = new Goods(shMaxColumnNum, Constant.ITEM_COLUMN_TYPE_COMMON);
                } else {
                    this.packageGoods.init(shMaxColumnNum, Constant.ITEM_COLUMN_TYPE_COMMON);
                }
                this.byTabIndex = 1;
                break;
            case Constant.ITEM_COLUMN_TYPE_TASK:
                if (this.taskPackageGoods == null) {
                    this.taskPackageGoods = new Goods(shMaxColumnNum, Constant.ITEM_COLUMN_TYPE_TASK);
                } else {
                    this.taskPackageGoods.init(shMaxColumnNum, Constant.ITEM_COLUMN_TYPE_TASK);
                }
                this.byTabIndex = 2;
                break;
            case Constant.ITEM_COLUMN_TYPE_PET:
                if (this.petPackageGoods == null) {
                    this.petPackageGoods = new Goods(shMaxColumnNum, Constant.ITEM_COLUMN_TYPE_PET);
                } else {
                    this.petPackageGoods.init(shMaxColumnNum, Constant.ITEM_COLUMN_TYPE_PET);
                }
                this.byTabIndex = 3;
                break;
        }

        this.iGoodsDescHeight = 0;
        this.bWaitMSGBack = false;
        this.bMoveGoods = false;
        this.bShowNumInput = false;
        this.bUseBindSignItem = false;
        this.byState = 0;
        this.shPos = -1;
        this.bySelectIndex = 1;
        this.byCurrentPage = 1;
        if (this.bSoldItems) {
            this.sOpArray = new String[]{"出售", "查看"};
        }
        if (!this.bSendShowBag) {//非通用包裹
            if (MainLogic.getInstance().byGameState != Constant.GAME_UI_PACKAGE) {
                this.bGetDataFromNet = new boolean[]{false, false, false};
                MainLogic.getInstance().pushState(Constant.GAME_UI_PACKAGE, true);
            } else {
                if (this.bySortItem == 1) {
                    this.bySortItem = -1;
                    this.bySelectIndex = 2;
                    this.shPos = 0;
                }
            }
            this.bGetDataFromNet[byTabIndex - 1] = true;
        } else {
            //通用包裹栏界面
            this.bSendShowBag = false;
            if (!bShowBAG) {
                this.bGetDataFromNet = new boolean[]{false, false, false};
                this.bShowBAG = true;
                MainLogic.getInstance().uiPackage.initPackage();
            }
            this.bGetDataFromNet[byTabIndex - 1] = true;
        }
        //界面中的位置的统一配置
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 46;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 21;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 26;
        //#endif
        this.lastSendDescTime = System.currentTimeMillis();
        this.setPackageState((byte) 0);
    }

    /**
     * 通用包裹的关闭
     */
    public void closeBag() {
        this.clearPackage();
    }

    public int setSelectLinePlace() {
        //#if NOKIA_S60V5
         switch (this.bySelectIndex) {
             case 1:
            return this.iStartPointY + 34;
             case 2:
             case 3:
             case 4:
             case 5:
                 return this.iStartPointY + 34+(Goods.byItemH + 3) * (this.bySelectIndex - 1);
             case 6:
                 return this.iStartPointY + 225;
             case 7:
                 return this.iStartPointY + 234 + Constant.FONT_SMALL_HEIGHT;
             default:
                 return this.iStartPointY + 34;
         }
        //#else
//#        switch (this.bySelectIndex) {
//#            case 1:
//#                return this.iStartPointY + 28;
//#            case 2:
//#            case 3:
//#            case 4:
//#            case 5:
//#                return this.iStartPointY + 28 + (Goods.byItemH + 1) * (this.bySelectIndex - 1);
//#            case 6:
//#                return this.iStartPointY + 172;
//#            case 7:
//#                return this.iStartPointY + 193;
//#            default:
//#                return this.iStartPointY + 28;
//#        }
        //#endif

    }

    /**
     * 初始化包裹界面
     */
    public void initPackage() {
        /****测试数据****************************/
//        this.packageGoods = new Goods((short) 29, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.taskPackageGoods = new Goods((short) 29, Constant.ITEM_COLUMN_TYPE_TASK);
//        this.petPackageGoods = new Goods((short) 29, Constant.ITEM_COLUMN_TYPE_PET);
//        this.packageGoods.addGoods((short) 0, true, -1, (short) -1, "下坡", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 1, true, -1, (short) -1, "下坡2", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 2, true, -1, (short) -1, "下坡3", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 3, true, -1, (short) -1, "下坡4", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 4, true, -1, (short) -1, "下坡", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 5, true, -1, (short) -1, "下坡2", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 6, true, -1, (short) -1, "下坡3", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 7, true, -1, (short) -1, "下坡4", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 8, true, -1, (short) -1, "下坡", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 9, true, -1, (short) -1, "下坡2", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 10, true, -1, (short) -1, "下坡3", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 11, true, -1, (short) -1, "下坡4", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 12, true, -1, (short) -1, "下坡", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 13, true, -1, (short) -1, "下坡2", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 14, true, -1, (short) -1, "下坡3", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods.addGoods((short) 15, true, -1, (short) -1, "下坡4", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//
//        this.taskPackageGoods.addGoods((short) 0, true, -1, (short) -1, "下坡", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.taskPackageGoods.addGoods((short) 1, true, -1, (short) -1, "下坡2", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.taskPackageGoods.addGoods((short) 2, true, -1, (short) -1, "下坡3", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.taskPackageGoods.addGoods((short) 3, true, -1, (short) -1, "下坡4", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.petPackageGoods.addGoods((short) 0, true, -1, (short) -1, "下坡", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.petPackageGoods.addGoods((short) 1, true, -1, (short) -1, "下坡2", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.petPackageGoods.addGoods((short) 2, true, -1, (short) -1, "下坡3", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.petPackageGoods.addGoods((short) 3, true, -1, (short) -1, "下坡4", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.bGetDataFromNet = new boolean[]{true, true, true};
        /**************************************/
//        this.byTabIndex = 1;
//        if (this.getCurrentPackage().checkColumnHasGoods((short) 0) && this.getCurrentPackage().getGoodsDesc((short) 0).length() > 0) {
//            this.iGoodsDescHeight = Tools.getParagraphHeight(this.getCurrentPackage().getGoodsDesc(this.shPos), 209, 16);
//        }
        this.bySortItem = -1;
        this.sArray = new String[]{"1 道具", "2 任务", "3 宠物", "4  进入商城", "6  整理背包", "售价：", "查看宠物", "提示", "您确定要丢弃该物品么", "请输入您要移动的物品数量", "您确定要绑定这件物品么？", "等级:", "确定", "取消", ""};//(0键快速翻页)
        //#if NOKIA_S60V5
         this.imgArray = new Image[16];
         this.imgArray[0] = ResManager.createImage(90000041); //小箭头图片
         this.imgArray[1] = Tools.makeBlueMask(); //蓝色选择条
         this.imgArray[2] = ResManager.createImage(90000017);//背景图片
         this.imgArray[3] = Tools.makeTransparent(ResManager.createImage(90000051), 255); //边框图片
         this.imgArray[4] = ResManager.createImage(90000086);//蓝条
         this.imgArray[5] = ResManager.createImage(90000043);  //文字图片
         this.imgArray[6] = ResManager.createImage(90000085);//确认按钮图片
         this.imgArray[7] = ResManager.createImage(90000084);//方向键图片
         this.imgArray[8] = Tools.makeTransparent(Constant.DRAW_WIDTH, 20, 180, 0x000000);            //弹出层背后的遮罩层
         this.imgArray[9] = ResManager.createImage(90000044);            //白色的确定取消文字
         this.imgArray[10] = ResManager.createImage(90000047);//翻页数字
         this.imgArray[11] = Tools.makeTransparent(28, 28, 80, 0xFFFFFF); //物品被选中的白色图片
         this.imgArray[12] = ResManager.createImage(90000063);//龙币文字
         this.imgArray[13] = ResManager.createImage(90000042);//龙币金银铜图片
         this.imgArray[14] = ResManager.createImage(90000095);//大箭头
         this.imgArray[15] = ResManager.createImage(90000049);        //星星图片
        //#else
//#        imgArray = new Image[15];
//#        //箭头图片
//#        this.imgArray[0] = ResManager.createImage(90000041);
//#        //蓝色光片
//#        this.imgArray[1] = Tools.makeBlueMask();
        //#if NOKIA_S40V3  || MOTO || K790
        //#elif NORMAL_240_400
//# //        imgArray[2] = ResManager.createImage(90000017);
//# //        imgArray[2] = Tools.ZoomImage(imgArray[2], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
        //#else
//#        //UI背景图片
//#        this.imgArray[2] = ResManager.createImage(90000017);
        //#endif
//#        //星星图片
//#        this.imgArray[3] = ResManager.createImage(90000049);
//#        this.imgArray[4] = Tools.makeTransparent(Constant.DRAW_WIDTH, 10, 140, 0x000000);        //整个界面的弹出背景遮罩层
//#        //文字图片（确定，取消）
//#        this.imgArray[5] = ResManager.createImage(90000060);
//#        //圆角图片//灰色
//#        this.imgArray[6] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
//#        //龙币图片
//#        this.imgArray[7] = ResManager.createImage(90000042);
//#        //龙币金银铜图片
//#        this.imgArray[8] = ResManager.createImage(90000063);
//#        //弹出提示层背景图片
//#        this.imgArray[9] = Tools.makeTransparent(20, 110, 220, 0x989898);
//#        //翻页数字
//#        this.imgArray[10] = ResManager.createImage(90000047);//大数字
//#        //白色确定
//#        this.imgArray[11] = ResManager.createImage(900000044);
//#        //输入框背景图片
//#        this.imgArray[12] = Tools.makeTransparent(218, 10, 220, 0x989898);
//#        this.imgArray[13] = Tools.makeTransparent(28, 28, 80, 0xFFFFFF); //物品被选中的白色图片
//#        this.imgArray[14] = ResManager.createImage(90000095); //大箭头
        //#endif
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 46;
        //#elif NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 21;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 26;
        //#endif
//        this.byTabIndex = 1;
//        this.bySelectIndex = 2;
//        this.shPos = 0;
//        this.byCurrentPage = 1;
//
//        this.setBagTotalPage();
//        this.setGoodsState();
//        this.iPositionY = setSelectLinePlace();
    }

    public void setPackageState(byte byAction) {
        if (byAction == 0) {
            this.setBagTotalPage();
        }
        switch (this.bySelectIndex) {
            case 1:
                switch (byAction) {
                    case 2://向下
                        this.bySelectIndex = 2;
                        this.bKeypressLock = true;
                        this.byState = 1;
                        this.shPos = (short) ((this.byCurrentPage - 1) * 28);
                        break;
                    case 3://向左
                        byte byNextTabIndex = byTabIndex == 1 ? 3 : (byte) (this.byTabIndex - 1);
                        if (this.bGetDataFromNet[byNextTabIndex - 1]) {
                            this.byTabIndex = byNextTabIndex;
                            this.byCurrentPage = 1;
                            this.setBagTotalPage();
                            this.shPos = 0;
                        } else {
                            if (this.bShowBAG) {
                                this.showBag(byNextTabIndex);//通用包裹
                            } else {
                                this.openBag(byNextTabIndex);//包裹界面
                            }
                        }
                        break;
                    case 4://向右
                        byNextTabIndex = byTabIndex == 3 ? 1 : (byte) (this.byTabIndex + 1);
                        if (this.bGetDataFromNet[byNextTabIndex - 1]) {
                            byTabIndex = byNextTabIndex;
                            this.byCurrentPage = 1;
                            setBagTotalPage();
                            this.lastSendDescTime = System.currentTimeMillis();
                            this.shPos = -1;
                        } else {
                            if (this.bShowBAG) {
                                this.showBag(byNextTabIndex);//通用包裹
                            } else {
                                this.openBag(byNextTabIndex);//包裹界面
                            }
                        }
                        break;
                }
                break;
            case 2:
                switch (byAction) {
                    case 1://向上  
                        this.bySelectIndex = 1;
                        this.shPos = -1;
                        this.bKeypressLock = true;
                        this.byState = 2;
                        break;
                    case 2://向下
                        this.bySelectIndex = 3;
                        this.shPos += 7;
                        this.bKeypressLock = true;
                        this.byState = 1;
                        break;
                    case 3://向左
                        this.shPos = (short) (this.shPos > (this.byCurrentPage - 1) * 28 ? this.shPos - 1 : (this.byCurrentPage - 1) * 28);
                        break;
                    case 4://向右
                        this.shPos += 1;
                        if (this.shPos == (this.byCurrentPage - 1) * 28 + 7) {
                            this.bySelectIndex = 3;
                            this.bKeypressLock = true;
                            this.byState = 1;
                        }
                        break;
                }
                break;
            case 3:
                switch (byAction) {
                    case 1://向上  
                        this.bySelectIndex = 2;
                        this.shPos -= 7;
                        this.bKeypressLock = true;
                        this.byState = 2;
                        break;
                    case 2://向下
                        this.bySelectIndex = 4;
                        this.shPos += 7;
                        this.bKeypressLock = true;
                        this.byState = 1;
                        break;
                    case 3://向左
                        this.shPos -= 1;
                        if (this.shPos == (this.byCurrentPage - 1) * 28 + 6) {
                            this.bySelectIndex = 2;
                            this.bKeypressLock = true;
                            this.byState = 2;
                        }
                        break;
                    case 4://向右
                        this.shPos += 1;
                        if (this.shPos == (this.byCurrentPage - 1) * 28 + 14) {
                            this.bySelectIndex = 4;
                            this.bKeypressLock = true;
                            this.byState = 1;
                        }
                        break;
                }
                break;
            case 4:
                switch (byAction) {
                    case 1://向上  
                        this.bySelectIndex = 3;
                        this.shPos -= 7;
                        this.bKeypressLock = true;
                        this.byState = 2;
                        break;
                    case 2://向下
                        this.bySelectIndex = 5;
                        this.shPos += 7;
                        this.bKeypressLock = true;
                        this.byState = 1;
                        break;
                    case 3://向左
                        this.shPos -= 1;
                        if (this.shPos == (this.byCurrentPage - 1) * 28 + 13) {
                            this.bySelectIndex = 3;
                            this.bKeypressLock = true;
                            this.byState = 2;
                        }
                        break;
                    case 4://向右
                        this.shPos += 1;
                        if (this.shPos == (this.byCurrentPage - 1) * 28 + 21) {
                            this.bySelectIndex = 5;
                            this.bKeypressLock = true;
                            this.byState = 1;
                        }
                        break;
                }
                break;
            case 5:
                switch (byAction) {
                    case 1://向上  
                        this.bySelectIndex = 4;
                        this.shPos -= 7;
                        this.bKeypressLock = true;
                        this.byState = 2;
                        break;
                    case 2://向下
                        this.bySelectIndex = 6;
                        this.byState = 1;
                        this.bKeypressLock = true;
                        this.shPos = -1;
                        this.bKeypressLock = true;
                        this.byState = 1;
                        break;
                    case 3://向左
                        this.shPos -= 1;
                        if (this.shPos == (this.byCurrentPage - 1) * 28 + 20) {
                            this.bySelectIndex = 4;
                            this.bKeypressLock = true;
                            this.byState = 2;
                        }
                        break;
                    case 4://向右
                        this.shPos = (short) (this.shPos < (this.byCurrentPage - 1) * 28 + 27 ? this.shPos + 1 : (this.byCurrentPage - 1) * 28 + 27);
                        break;
                }
                break;
            case 6:
                switch (byAction) {
                    case 1://向上  
                        this.bySelectIndex = 5;
                        this.byState = 2;
                        this.bKeypressLock = true;
                        this.shPos = (short) ((this.byCurrentPage - 1) * 28 + 21);
                        this.bKeypressLock = true;
                        this.byState = 2;
                        break;
                    case 2://向下
                        this.bySelectIndex = 7;
                        this.byState = 1;
                        this.bySubSelectIndex = 1;
                        this.bKeypressLock = true;
                        this.byState = 1;
                        break;
                    case 3://向左
                        if (this.byCurrentPage > 1) {
                            this.byCurrentPage = (byte) (this.byCurrentPage - 1);
                        }
                        break;
                    case 4://向右
                        if (this.byCurrentPage < this.byTotalPage) {
                            this.byCurrentPage = (byte) (this.byCurrentPage + 1);
                        }
                        break;
                }
                break;
            case 7:
                switch (byAction) {
                    case 1://向上  
                        this.bySelectIndex = 6;
                        this.byState = 1;
                        this.bKeypressLock = true;
                        break;
                    case 3://向左
                    case 4://向右
                        this.bySubSelectIndex = (byte) (this.bySubSelectIndex == 1 ? 2 : 1);
                        break;
                }
                break;

        }
        if (bKeypressLock) {
            this.iArray = new int[]{this.byState, 1, this.setSelectLinePlace(), 2, 50, 20};
        } else {
            this.iPositionY = this.setSelectLinePlace();
        }
        if (this.bySelectIndex < 2 || this.bySelectIndex > 6) {
            this.clearSpecialState();
        }
        this.setGoodsState();
    }

    public void setGoodsState() {
        if (this.getCurrentPackage().checkColumn(this.shPos) == 1) {
            if (this.getCurrentPackage().getGoodsDesc(this.shPos).length() > 0) {
                //#if NOKIA_S60V5
                 this.iGoodsDescHeight = Tools.getParagraphHeight(this.getCurrentPackage().getGoodsDesc(this.shPos), 300, Constant.FONT_SMALL_HEIGHT);
                //#else
//#                this.iGoodsDescHeight = Tools.getParagraphHeight(this.getCurrentPackage().getGoodsDesc(this.shPos), 209, Constant.FONT_SMALL_HEIGHT);
                //#endif
            }
            this.makeItemsTips();
        }
    }

    /**
     * 包裹界面的更新
     */
    public void updatePackage() {
        switch (this.byUiState) {
            case 0:
                if (!GameBean.b_WAIT_NET_MSG_BACK) {
                    if (!bKeypressLock) {
                        if (!bShowMenu) {
                            //非弹出物品操作菜单
                            if (!this.bShowNumInput) {
                                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                    if (this.bySelectIndex > 1) {
                                        this.setPackageState((byte) 1);
                                    }
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                    byte byMaxSelectIndex;
                                    if (this.bSoldItems || this.bShowBAG) {
                                        byMaxSelectIndex = 6;
                                    } else {
                                        byMaxSelectIndex = 7;
                                    }
                                    if (this.bySelectIndex < byMaxSelectIndex) {
                                        this.setPackageState((byte) 2);
                                    }
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                                    this.setPackageState((byte) 3);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                                    this.setPackageState((byte) 4);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_0, false)) {
                                    this.bySelectIndex = 6;
                                    this.shPos = -1;
                                    this.iPositionY = this.setSelectLinePlace();
                                    this.byCurrentPage = (byte) (this.byCurrentPage == this.byTotalPage ? 1 : this.byCurrentPage + 1);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_1, false)) {
                                    if (this.byTabIndex == 1) {
                                        return;
                                    }
                                    if (this.bGetDataFromNet[0]) {
                                        byTabIndex = 1;
                                        this.byCurrentPage = 1;
                                        setBagTotalPage();
                                        this.lastSendDescTime = System.currentTimeMillis();
                                        this.shPos = -1;
                                    } else {
                                        if (this.bShowBAG) {
                                            this.showBag((byte) 1);//通用包裹
                                        } else {
                                            this.openBag((byte) 1);//包裹界面
                                        }
                                    }
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_2, false)) {
                                    if (this.bGetDataFromNet[1]) {
                                        byTabIndex = 2;
                                        this.byCurrentPage = 1;
                                        setBagTotalPage();
                                        this.lastSendDescTime = System.currentTimeMillis();
                                        this.shPos = -1;
                                    } else {
                                        if (this.bShowBAG) {
                                            this.showBag((byte) 2);//通用包裹
                                        } else {
                                            this.openBag((byte) 2);//包裹界面
                                        }
                                    }
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_3, false)) {
                                    if (this.bGetDataFromNet[2]) {
                                        byTabIndex = 3;
                                        this.byCurrentPage = 1;
                                        setBagTotalPage();
                                        this.lastSendDescTime = System.currentTimeMillis();
                                        this.shPos = -1;
                                    } else {
                                        if (this.bShowBAG) {
                                            this.showBag((byte) 3);//通用包裹
                                        } else {
                                            this.openBag((byte) 3);//包裹界面
                                        }
                                    }
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_4, false)) {
                                    MainLogic.getInstance().uiInterFace.store.openIngotStore((byte) 1, (byte) 1);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_6, false)) {
                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                    if (this.bShowBAG) {
                                        this.bSendShowBag = true;
                                    }
                                    this.sortBagItems(this.byTabIndex);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                                    switch (this.bySelectIndex) {
                                        case 2:
                                        case 3:
                                        case 4:
                                        case 5:
                                            if (!this.bShowBAG) {
                                                if (this.bMoveGoods) {
                                                    //移动物品
                                                    if (this.shMoveIndex == this.shPos || this.shPos == -1 || this.byRecordTabIndex != this.byTabIndex || this.shPos >= this.getCurrentPackage().getMaxColumNum()) {
                                                        this.clearSpecialState();
                                                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您不能移动道具到这个位置！");
                                                    } else {
                                                        //移动物品
                                                        GameBean.b_WAIT_NET_MSG_BACK = true;
                                                        this.shMoveDestIndex = this.shPos;
                                                        GameBean.I_CMD_COLUMN_INDEX = this.shPos;
                                                        GameBean.BY_GOODS_NUM = (byte) this.shMoveNum;
                                                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_MOVE_ITEM, Constant.SOCKET_MSG_TYPE_LOGIC);
                                                    }
                                                } else if (this.bUseBindSignItem && this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                    //发送送绑定指令
                                                    if (this.getCurrentPackage().getGoodsCatalog(this.shPos) == Constant.ITEM_TYPE_EQUIP || this.getCurrentPackage().getGoodsCatalog(this.shPos) == Constant.ITEM_TYPE_WEAPONS) {
                                                        this.byUiState = 6;
                                                        this.sArray[10] = "您确定要绑定该道具么？";
                                                        this.byPopUpState = 1;
                                                        this.clearSpecialState();
                                                    } else {
                                                        this.clearSpecialState();
                                                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您不可以绑定该道具！");
                                                    }
                                                } else if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                    this.bShowMenu = true;
                                                    this.byMenuIndex = 0;
                                                    Tools.printLog("this.shPos=" + this.shPos);
                                                    this.sOpArray = this.getCurrentPackage().getGoodsOpArray(this.shPos);
                                                }
                                            } else {
                                                switch (MainLogic.getInstance().byGameState) {
                                                    case Constant.GAME_UI_PET_EQUIP:
                                                        //宠物装备界面
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            MainLogic.getInstance().uiInterFace.pet.petEquipSelectItem(this.getCurrentPackage(), this.shPos);
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_GAMESET_QUICKEYS:
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            String goodtype = this.getCurrentPackage().getGoodsKey(this.shPos);
//                                                            System.out.println("goodtype ::: " + goodtype);
                                                            if (goodtype.substring(0, 2).equals("10") || goodtype.substring(0, 2).equals("80")) {
                                                                GameSet.getQuickSet("" + 2, "" + this.getCurrentPackage().iIconID[this.shPos],
                                                                        "" + this.getCurrentPackage().getGoodsColumnKey(this.shPos),
                                                                        this.getCurrentPackage().getGoodsAlias(this.shPos),
                                                                        this.getCurrentPackage().getGoodsDesc(this.shPos),
                                                                        "" + this.getCurrentPackage().getGoodsStackNum(this.shPos));
                                                                this.closeBag();
                                                            } else {
                                                                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该物品不能设置快捷!");
                                                            }
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_CHAT:
                                                    case Constant.GAME_UI_SMILE:
                                                        //插入任务物品
                                                        if (this.byTabIndex == 1 && this.shPos < this.packageGoods.getMaxColumNum() && this.packageGoods.checkColumnHasGoods(this.shPos)) {
                                                            GameBean.L_CMD_GOODS_SLOTKEY = this.packageGoods.getGoodsColumnKey(this.shPos);
//                                                            GameBean.STR_CDM_GOODS_KEY = this.packageGoods.getGoodsKey(this.shPos);
                                                            GameBean.STR_CMD_GOODS_NAME = this.packageGoods.getGoodsAlias(this.shPos);
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[0] = "" + GameBean.L_CMD_GOODS_SLOTKEY;
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[1] = "[" + GameBean.STR_CMD_GOODS_NAME + "]";
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[2] = "" + 0 + this.packageGoods.getGoodsIconID(this.shPos);
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[3] = "" + this.packageGoods.byColor[this.shPos];
                                                            if (MainLogic.getInstance().uiEquipment.taskORitems_ID[0] != null) {
                                                                Tools.printLog("GameBean.STR_CMD_QUEST_KEY  :::" + MainLogic.getInstance().uiEquipment.taskORitems_ID[0]);
//                                                                Tools.printLog("col  ::::::::::::::::  "+this.packageGoods.byColor[this.shPos]);
//                                                                Tools.printLog("col222  ::::::::::::::::  "+this.packageGoods.getGoodsNameColor(this.packageGoods.byColor[this.shPos]));
                                                                Tools.printLog("icon  :::" + this.packageGoods.getGoodsIconID(this.shPos));
                                                                MainLogic.getInstance().pushState(Constant.GAME_UI_CHAT, true);
                                                                MainLogic.getInstance().uiEquipment.taskORitems_new = "*"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[0] + "<"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[1] + ">"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[2] + "$"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[3] + "@";
                                                                MainLogic.getInstance().inputInterFace.commonInput.setString(
                                                                        MainLogic.getInstance().inputInterFace.commonInput.getString() + "/%");
                                                                // MainGame.changeCanvas(InputInterFace.inputInterItems);
                                                                MainGame.changeCanvas(MainLogic.getInstance().inputInterFace.inputInterItems);
                                                                GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT;
                                                                this.closeBag();
                                                            }
                                                        } else if (this.byTabIndex == 2 && this.shPos < this.taskPackageGoods.getMaxColumNum() && this.taskPackageGoods.checkColumnHasGoods(this.shPos)) {
                                                            GameBean.L_CMD_GOODS_SLOTKEY = this.taskPackageGoods.getGoodsColumnKey(this.shPos);
//                                                            GameBean.STR_CDM_GOODS_KEY = this.packageGoods.getGoodsKey(this.shPos);
                                                            GameBean.STR_CMD_GOODS_NAME = this.taskPackageGoods.getGoodsAlias(this.shPos);
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[0] = "" + GameBean.L_CMD_GOODS_SLOTKEY;
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[1] = "[" + GameBean.STR_CMD_GOODS_NAME + "]";
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[2] = "" + 0 + this.packageGoods.getGoodsIconID(this.shPos);
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[3] = "" + this.packageGoods.byColor[this.shPos];
                                                            if (MainLogic.getInstance().uiEquipment.taskORitems_ID[0] != null) {
                                                                Tools.printLog("GameBean.STR_CMD_QUEST_KEY  :::" + MainLogic.getInstance().uiEquipment.taskORitems_ID[0]);
                                                                MainLogic.getInstance().pushState(Constant.GAME_UI_CHAT, true);
                                                                MainLogic.getInstance().uiEquipment.taskORitems_new = "*"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[0] + "<"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[1] + ">"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[2] + "$"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[3] + "@";
                                                                MainLogic.getInstance().inputInterFace.commonInput.setString(
                                                                        MainLogic.getInstance().inputInterFace.commonInput.getString() + "/%");
                                                                //MainGame.changeCanvas(InputInterFace.inputInterItems);
                                                                MainGame.changeCanvas(MainLogic.getInstance().inputInterFace.inputInterItems);
                                                                GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT;
                                                                this.closeBag();
                                                            }
                                                        } else if (this.byTabIndex == 3 && this.shPos < this.petPackageGoods.getMaxColumNum() && this.petPackageGoods.checkColumnHasGoods(this.shPos)) {
                                                            GameBean.L_CMD_GOODS_SLOTKEY = this.petPackageGoods.getGoodsColumnKey(this.shPos);
//                                                            GameBean.STR_CDM_GOODS_KEY = this.packageGoods.getGoodsKey(this.shPos);
                                                            GameBean.STR_CMD_GOODS_NAME = this.petPackageGoods.getGoodsAlias(this.shPos);
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[0] = "" + GameBean.L_CMD_GOODS_SLOTKEY;
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[1] = "[" + GameBean.STR_CMD_GOODS_NAME + "]";
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[2] = "" + 2 + this.packageGoods.getGoodsIconID(this.shPos);
                                                            MainLogic.getInstance().uiEquipment.taskORitems_ID[3] = "" + this.packageGoods.byColor[this.shPos];
                                                            if (MainLogic.getInstance().uiEquipment.taskORitems_ID[0] != null) {
                                                                Tools.printLog("GameBean.STR_CMD_QUEST_KEY  :::" + MainLogic.getInstance().uiEquipment.taskORitems_ID[0]);
                                                                MainLogic.getInstance().pushState(Constant.GAME_UI_CHAT, true);
                                                                MainLogic.getInstance().uiEquipment.taskORitems_new = "*"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[0] + "<"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[1] + ">"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[2] + "$"
                                                                        + MainLogic.getInstance().uiEquipment.taskORitems_ID[3] + "@";
                                                                MainLogic.getInstance().inputInterFace.commonInput.setString(
                                                                        MainLogic.getInstance().inputInterFace.commonInput.getString() + "/%");
                                                                //MainGame.changeCanvas(InputInterFace.inputInterItems);
                                                                MainGame.changeCanvas(MainLogic.getInstance().inputInterFace.inputInterItems);
                                                                GameBean.BY_PRE_GAME_UI_STATE = Constant.GAME_UI_CHAT;
                                                                this.closeBag();
                                                            }
                                                        } else {
                                                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请选择您要插入的物品");
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_PET_COMPOSE:
                                                        //宠物合成
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            if (this.byTabIndex != 3) {
                                                                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的不是宠物");
                                                            } else {
                                                                MainLogic.getInstance().uiInterFace.pet.selectPetFromBg(petPackageGoods, shPos);
                                                            }
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_ITEMS_COMPOSE:
                                                        //装备合成
                                                        if (this.byTabIndex == 1 && this.packageGoods.checkColumnHasGoods(this.shPos)) {
                                                            MainLogic.getInstance().uiInterFace.equipment.selectComposeItem(packageGoods, this.shPos);
                                                        } else if (this.byTabIndex == 2 && this.taskPackageGoods.checkColumnHasGoods(this.shPos)) {
                                                            MainLogic.getInstance().uiInterFace.equipment.selectComposeItem(taskPackageGoods, this.shPos);
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_ITEMS_DECOMPOSE:
                                                        //装备分解
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            MainLogic.getInstance().uiInterFace.equipment.selectDeComposeItem(this.getCurrentPackage(), this.shPos);
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_ITEMS_STRENGTHEN:
                                                        //物品强化
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            MainLogic.getInstance().uiInterFace.equipment.selectStrengthenItem(this.getCurrentPackage(), shPos);
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_EQUIP_OPERATION:
                                                        //物品镶嵌打孔拆分
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            MainLogic.getInstance().uiInterFace.equipment.selectEquipOperationItems(this.getCurrentPackage(), shPos);
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_SEND_EMAIL:
                                                        //发送邮件
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            int isselect = 0;
                                                            for (int i = 0; i < MainLogic.getInstance().uiEquipment.isSelected.length; i++) {
                                                                if (MainLogic.getInstance().uiEquipment.isSelected[i][1] == this.shPos
                                                                        && MainLogic.getInstance().uiEquipment.isSelected[i][0] == 1) {
                                                                    isselect = 1;
                                                                }
                                                            }
                                                            if (isselect == 0) {
                                                                if (this.getCurrentPackage().getGoodsBind(this.shPos) != 1) {
                                                                    MainLogic.getInstance().uiEquipment.isSelected[MainLogic.getInstance().uiEquipment.addgoods_index][0] = 1;
                                                                    MainLogic.getInstance().uiEquipment.isSelected[MainLogic.getInstance().uiEquipment.addgoods_index][1] = this.shPos;
                                                                    MainLogic.getInstance().uiEquipment.items.goodsClone((short) MainLogic.getInstance().uiEquipment.addgoods_index, this.getCurrentPackage(), this.shPos);
                                                                    this.closeBag();
                                                                } else {
                                                                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "绑定物品不能添加!");
                                                                }
                                                            } else {
                                                                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该物品您已经选择过了!");
                                                            }
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_STORE_SOLD:
                                                        //出售物品
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            this.bShowMenu = true;
                                                            this.byMenuIndex = 0;
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_WAREHOUSE:
                                                        //仓库
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            GameBean.b_WAIT_NET_MSG_BACK = true;
                                                            GameBean.BY_TYPE = 1;
                                                            MainLogic.getInstance().uiInterFace.store.byOpState = 1;
                                                            GameBean.L_CMD_GOODS_SLOTKEY = this.getCurrentPackage().getGoodsColumnKey(this.shPos);
                                                            GameBean.L_NPC_ID = MainLogic.getInstance().uiInterFace.store.lNpcID;
                                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_FUNC_DEPOT, Constant.SOCKET_MSG_TYPE_LOGIC);
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_TRADE:
                                                        //交易
                                                        if (MainLogic.getInstance().uiInterFace.store.myItems.getGoodsNum() >= 14) {
                                                            MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "交易物品已满!");
                                                            return;
                                                        }
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            GameBean.L_CMD_GOODS_SLOTKEY = this.getCurrentPackage().getGoodsColumnKey(this.shPos);
                                                            for (byte i = 0; i < 14; i++) {
                                                                if (MainLogic.getInstance().uiInterFace.store.myItems.checkColumnHasGoods(i) && GameBean.L_CMD_GOODS_SLOTKEY == MainLogic.getInstance().uiInterFace.store.myItems.getGoodsColumnKey(i)) {
                                                                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该物品您已经选择过了!");
                                                                    return;
                                                                }
                                                            }
                                                            GameBean.b_WAIT_NET_MSG_BACK = true;
                                                            GameBean.L_PLAYER_ID = MainLogic.getInstance().uiInterFace.store.lTraderID;
                                                            GameBean.I_MONEY = 0;
                                                            GameBean.BY_TYPE = 1;//1.同步物品，2，同步金钱
                                                            GameBean.BY_OP_TYPE = 1;//1，添加。0删除
                                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_SYNC_TRADE_ITEM, Constant.SOCKET_MSG_TYPE_LOGIC);
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_PET_POWER_STRENGTHEN:
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            MainLogic.getInstance().uiInterFace.pet.selectPetPowerStrengthItems(this.getCurrentPackage(), shPos);
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_PLAYER_STALL:
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            GameBean.BY_TYPE = 1;
                                                            GameBean.L_PLAYER_ID = MainLogic.getInstance().gamePlayer.lPlayerID;
                                                            GameBean.L_CMD_GOODS_SLOTKEY = this.getCurrentPackage().getGoodsColumnKey(this.shPos);
                                                            this.iArray = new int[5];
                                                            this.iArray[0] = 1;
                                                            this.iArray[1] = this.getCurrentPackage().getGoodsPrice(shPos) / 10000;
                                                            this.iArray[2] = (this.getCurrentPackage().getGoodsPrice(shPos) - this.iArray[1] * 10000) / 100;
                                                            this.iArray[3] = this.getCurrentPackage().getGoodsPrice(shPos) - this.iArray[1] * 10000 - this.iArray[2] * 100;
                                                            this.iArray[4] = 1;
                                                            GameBean.BY_TYPE = 1;
                                                            GameBean.L_CMD_GOODS_SLOTKEY = this.getCurrentPackage().getGoodsColumnKey(this.shPos);
                                                            //#if NOKIA_S60V5
                                                             MainLogic.getInstance().inputInterFace.setInputInterFace((byte) 1, "请输入物品新价格：");
                                                             MainLogic.getInstance().inputInterFace.commonInput2.setString(String.valueOf(this.iArray[1]));
                                                             MainLogic.getInstance().inputInterFace.commonInput3.setString(String.valueOf(this.iArray[2]));
                                                             MainLogic.getInstance().inputInterFace.commonInput4.setString(String.valueOf(this.iArray[3]));
                                                             MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                                                            //#else
//#                                                            this.byUiState = 7;
                                                            //#endif
                                                        }
                                                        break;
                                                    case Constant.GAME_UI_HANGUP://挂机
                                                        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos)) {
                                                            if (MainLogic.getInstance().uiInterFace.property.byState == 1) {//在线挂机
                                                                if (MainLogic.getInstance().uiInterFace.property.bySelectIndex == 3) {//选择红药物品
                                                                    if (getCurrentPackage().sGoodsKey[shPos].equals("10001")//止血草
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10002")//仙鹤草
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10003")//血参
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10004")//云南白药
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10005")//小行血药
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10006")//大型血药
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10007")//琼丹妙露
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10015")//蜂王蜜
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10016")//鼠儿果
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10017")//赤炎果
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10018")//无忧仙果
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10019")//天心海棠
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10020")//独龙内丹
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10021")//玄天异果
                                                                            ) {
                                                                        MainLogic.getInstance().uiInterFace.property.hangUpGoods.goodsClone((short) (MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1),
                                                                                this.getCurrentPackage(), this.shPos);
                                                                        Property.goodsIcon[MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().icon[shPos];
                                                                        Property.goodsColor[MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().byColor[shPos];
                                                                        Property.goodsNum[MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().shStackNum[shPos];
                                                                        Property.goodsByBind[MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().byBind[shPos];
                                                                        Property.goodsKey[MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().getGoodsColumnKey(this.shPos);
                                                                        closeBag();
                                                                    } else {
                                                                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请选择正确的补血物品!", (byte) 1, (byte) -1);
                                                                    }
                                                                } else if (MainLogic.getInstance().uiInterFace.property.bySelectIndex == 4) {//选择蓝药物品
                                                                    if (getCurrentPackage().sGoodsKey[shPos].equals("10008")//红花
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10009")//当归
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10010")//炸酱草
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10011")//越橘药
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10012")//小活络药
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10013")//大活络药
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10014")//活络秘药
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10015")//蜂王蜜
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10016")//鼠儿果
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10017")//赤炎果
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10018")//无忧仙果
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10019")//天心海棠
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10020")//独龙内丹
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("10021")//玄天异果
                                                                            ) {
                                                                        MainLogic.getInstance().uiInterFace.property.hangUpGoods.goodsClone((short) (3 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1),
                                                                                this.getCurrentPackage(), this.shPos);
                                                                        Property.goodsIcon[3 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().icon[shPos];
                                                                        Property.goodsColor[3 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().byColor[shPos];
                                                                        Property.goodsNum[3 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().shStackNum[shPos];
                                                                        Property.goodsByBind[3 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().byBind[shPos];
                                                                        Property.goodsKey[3 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().getGoodsColumnKey(this.shPos);
                                                                        closeBag();
                                                                    } else {
                                                                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请选择正确的补蓝物品!", (byte) 1, (byte) -1);
                                                                    }
                                                                } else if (MainLogic.getInstance().uiInterFace.property.bySelectIndex == 5) {//选择经验卡
                                                                    if (getCurrentPackage().sGoodsKey[shPos].equals("80001")//2倍经验卡
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("80002")//强效2倍经验卡
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("80003")//特效2倍经验卡
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("80004")//3倍经验卡
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("80005")//2倍经验卡（绑）
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("80006")//强效2倍经验卡（绑）
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("80007")//特效2倍经验卡（绑）
                                                                            || getCurrentPackage().sGoodsKey[shPos].equals("80008")//3倍经验卡（绑）
                                                                            ) {
                                                                        MainLogic.getInstance().uiInterFace.property.hangUpGoods.goodsClone((short) (6 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1),
                                                                                this.getCurrentPackage(), this.shPos);
                                                                        Property.goodsIcon[6 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().icon[shPos];
                                                                        Property.goodsColor[6 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().byColor[shPos];
                                                                        Property.goodsNum[6 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().shStackNum[shPos];
                                                                        Property.goodsByBind[6 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().byBind[shPos];
                                                                        Property.goodsKey[6 + MainLogic.getInstance().uiInterFace.property.bySubSelectIndex - 1] = getCurrentPackage().getGoodsColumnKey(this.shPos);
                                                                        closeBag();
                                                                    } else {
                                                                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请选择经验卡道具!", (byte) 1, (byte) -1);
                                                                    }
                                                                }
                                                            } else if (MainLogic.getInstance().uiInterFace.property.byState == 2) {//离线挂机
                                                                if (getCurrentPackage().sGoodsKey[shPos].equals("90031")
                                                                        || getCurrentPackage().sGoodsKey[shPos].equals("90032")
                                                                        || getCurrentPackage().sGoodsKey[shPos].equals("90033")) {
                                                                    GameBean.L_CMD_GOODS_SLOTKEY = this.getCurrentPackage().getGoodsColumnKey(this.shPos);
                                                                    MainLogic.getInstance().uiInterFace.property.hangUpGoods.goodsClone((short) 0, this.getCurrentPackage(), this.shPos);
                                                                    closeBag();
                                                                    MainLogic.getInstance().uiInterFace.property.setExp();
                                                                } else {
                                                                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "请选择正确的增幅道具!", (byte) 1, (byte) -1);
                                                                }
                                                            }
                                                        }
                                                        break;
                                                }
                                            }
                                            break;
                                        case 7:
                                            if (!this.bShowBAG) {
                                                switch (this.bySubSelectIndex) {
                                                    case 1:
                                                        MainLogic.getInstance().uiInterFace.store.openIngotStore((byte) 1, (byte) 1);
                                                        break;
                                                    case 2:
                                                        GameBean.b_WAIT_NET_MSG_BACK = true;
                                                        if (this.bShowBAG) {
                                                            this.bSendShowBag = true;
                                                        }
                                                        this.sortBagItems(this.byTabIndex);
                                                        break;
                                                }
                                            }
                                            break;
                                    }
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                    if (!this.bShowBAG) {
                                        //跳转到漫游界面
                                        if (this.bMoveGoods || this.bUseBindSignItem) {
                                            clearSpecialState();
                                        } else {
                                            Tools.openRoamMenu(false, (byte) 1, (byte) 0, 5);
                                        }
                                    } else {
                                        this.closeBag();
                                        if (MainLogic.getInstance().byGameState == Constant.GAME_UI_STORE_SOLD) {
                                            MainLogic.pushState(Constant.GAME_UI_ROAM, true);
                                            this.bSoldItems = false;
                                        } else if (MainLogic.getInstance().byGameState == Constant.GAME_UI_WAREHOUSE) {
                                            GameBean.L_NPC_ID = MainLogic.getInstance().uiInterFace.store.lNpcID;
                                            MainLogic.getInstance().pushState(Constant.GAME_UI_ROAM, true);
                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_DEPOT, Constant.SOCKET_MSG_TYPE_LOGIC);
                                        } else if (MainLogic.getInstance().byGameState == Constant.GAME_UI_PET_EQUIP) {
                                            GameBean.b_WAIT_NET_MSG_BACK = true;
                                            MainLogic.getInstance().send(Constant.MSG_NET_CMD_OPEN_PET, Constant.SOCKET_MSG_TYPE_LOGIC);
                                        }
                                    }
                                } else {
                                    if (this.bySelectIndex >= 2 && this.bySelectIndex <= 5) {
                                        //#if NOKIA_E72
                                        //#else
                                        this.getGoodsDescFromNet();
                                        //#endif
                                    }
                                }
                            } else {
                                //输入移动物品的数字
                                this.bShowFlash = this.bShowFlash == true ? false : true;
                                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                                    this.byUiState = 0;
                                    if (this.shMoveNum < 1 || this.shMoveNum > this.getCurrentPackage().getGoodsStackNum(shMoveIndex)) {
                                        MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您输入的物品数量不正确!");
                                    } else {
                                        this.bShowNumInput = false;
                                    }
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                    this.clearSpecialState();
                                } else {
                                    this.shMoveNum = (short) Tools.updateInputCanvas(this.shMoveNum, this.getCurrentPackage().getGoodsStackNum(shMoveIndex));
                                }
                            }
                        } else {
                            if (this.bySelectIndex < 2 || this.bySelectIndex > 5) {
                                this.bShowMenu = false;
                                return;
                            } else {
                                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                    this.bShowMenu = false;
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 0);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                    this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 1);
                                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                                    this.bShowMenu = false;
                                    byte opType = this.getCurrentPackage().getOperationType(this.sOpArray, this.byMenuIndex);
                                    if (opType == Constant.ITEM_OPERATION_TYPE_DELETE) {
                                        this.byUiState = 4;
                                        if (this.getCurrentPackage().getGoodsCatalog(this.shPos) == Constant.ITEM_TYPE_PETS) {
                                            this.sArray[8] = "放生后宠物将消失，是否确定放生？";
                                        } else {
                                            this.sArray[8] = "您确定要丢弃该道具么？";
                                        }
                                        this.byPopUpState = 1;
                                    } else if (opType == Constant.ITEM_OPERATION_TYPE_MOVE) {
                                        //移动物品
                                        this.bMoveGoods = true;
                                        this.shMoveIndex = this.shPos;
                                        GameBean.L_CMD_GOODS_SLOTKEY = this.getCurrentPackage().getGoodsColumnKey(shMoveIndex);
                                        if (this.getCurrentPackage().getGoodsStackNum(this.shPos) > 1) {
                                            this.shMoveNum = 1;
                                            //#if NOKIA_S60V5
                                             MainLogic.getInstance().inputInterFace.setInputInterFace((byte) 1, "请输入要移动的物品数量:");
                                             MainLogic.getInstance().inputInterFace.commonInput.setString(String.valueOf(this.shMoveNum));
                                             MainGame.changeCanvas(MainLogic.getInstance().inputInterFace);
                                            //#else
//#                                            this.bShowNumInput = true;
                                            //#endif
                                        } else {
                                            this.shMoveNum = 1;
                                        }
                                        this.byRecordTabIndex = this.byTabIndex;
                                    } else if (opType == Constant.ITEM_OPERATION_TYPE_USE && (this.getCurrentPackage().getGoodsKey(this.shPos).equals("15054") || this.getCurrentPackage().getGoodsKey(this.shPos).equals("15101"))) {
                                        this.bShowMenu = false;
                                        this.bUseBindSignItem = true;
                                        this.byRecordTabIndex = this.byTabIndex;
                                        this.shRecordItemIndex = this.shPos;
                                        GameBean.L_BIND_SIGN_KEY = this.getCurrentPackage().getGoodsColumnKey(this.shPos);
                                    } else {
                                        GameBean.b_WAIT_NET_MSG_BACK = true;
                                        this.getCurrentPackage().sendGoodsOperationMSG(this.shPos, opType);
                                    }
                                }
                            }
                        }
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            iPositionY = Tools.updateLinePos(this.iArray, iPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bKeypressLock = false;
                            }
                        }
                        MainCanvas.clearInput();
                    }
                }
                break;
            case 4:
                //删除物品
                if (this.byPopUpState >= 4) {
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                        //发送消息
                        this.byUiState = 0;
                        this.bKeypressLock = false;
                        //发送分解信息
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        this.getCurrentPackage().sendGoodsOperationMSG(this.shPos, Constant.ITEM_OPERATION_TYPE_DELETE);
                        break;
                    } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                        this.bKeypressLock = false;
                        this.byUiState = 0;
                    }
                } else {
                    this.byPopUpState++;
                }
                break;
            case 6:
                //使用绑定符号
                if (this.byPopUpState >= 4) {
                    if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                        //发送消息
                        this.byUiState = 0;
                        this.bKeypressLock = false;
                        //发送使用绑定消息
                        GameBean.b_WAIT_NET_MSG_BACK = true;
                        GameBean.L_CMD_GOODS_SLOTKEY = this.getCurrentPackage().getGoodsColumnKey(this.shPos);
                        MainLogic.getInstance().send(Constant.MSG_NET_CMD_EQUIP_BIND, Constant.SOCKET_MSG_TYPE_LOGIC);
                        break;
                    } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                        this.byUiState = 0;
                    }
                } else {
                    this.byPopUpState++;
                }
                break;
            case 7://输入摆摊物品的价格
                if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                    this.byUiState = 0;
                    GameBean.I_MONEY = (this.iArray[1] > 0 ? this.iArray[1] * 10000 : 0) + (this.iArray[2] > 0 ? this.iArray[2] * 100 : 0) + (this.iArray[3] > 0 ? this.iArray[3] : 0);
                    GameBean.BY_TYPE = 1;
                    MainLogic.getInstance().send(Constant.MSG_NET_CMD_BUSINESS_OPT, Constant.SOCKET_MSG_TYPE_LOGIC);
                    //发送调整信息
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                    this.iArray[0] = this.iArray[0] == 1 ? 3 : this.iArray[0] - 1;
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                    this.iArray[0] = this.iArray[0] == 3 ? 1 : this.iArray[0] + 1;
                } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                    this.byUiState = 0;
                } else {
                    switch (this.iArray[0]) {
                        case 1:
                            this.iArray[1] = Tools.updateInputCanvas(this.iArray[1], 9999);
                            break;
                        case 2:
                            this.iArray[2] = Tools.updateInputCanvas(this.iArray[2], 99);
                            break;
                        case 3:
                            this.iArray[3] = Tools.updateInputCanvas(this.iArray[3], 99);
                            break;
                    }
                }
                this.iArray[4] = this.iArray[4] == 1 ? 0 : 1;
                break;
        }
        MainCanvas.clearInput();
    }

    /**
     * 绘制物品的背景
     * @param g
     * @param byTabNum
     * @param bySelectIndex
     * @param sArray
     * @param startX
     * @param startY
     * @param boxImg
     */
    public void drawPackageBg(Graphics g, int startX, int startY, Image boxImg) {
        //#if NOKIA_S60V5
         //左面的
         Tools.drawTilePic(g, (byte) 2, startX, startY + 34, 270 - 34 - 13, boxImg, 14, 0, 13, 13, Constant.TRANS_NONE);
         //右面的
         Tools.drawTilePic(g, (byte) 2, startX + 318 - 13, startY + 34, 270 - 34 - 13, boxImg, 14, 0, 13, 13, Constant.TRANS_ROT180);
         //下面的
         Tools.drawTilePic(g, (byte) 1, startX + 13, startY + 270 - 13, 318 - 26, boxImg, 14, 14, 13, 13, Constant.TRANS_NONE);//下面
         //底部
         g.drawRegion(boxImg, 0, 14, 13, 13, Constant.TRANS_NONE, startX, startY + 270 - 13, 0); //左下角
         g.drawRegion(boxImg, 0, 14, 13, 13, Constant.TRANS_ROT270, startX + 318 - 13, startY + 270 - 13, 0); //右下角
         //填充中间的部分呢
         g.setColor(0x9c9c9c);
         g.fillRect(startX + 13, startY + 34, 292, 224);
         int iTabWidth = 104;
         for (byte i = 0; i < 3; i++) {
             g.setColor(0x9c9c9c);
             g.fillRect(startX + 13, startY + 13, iTabWidth - 26, 34 - 13);
             g.drawRegion(boxImg, 0, 0, 13, 13, Constant.TRANS_NONE, startX, startY, 0); //左上角
             g.drawRegion(boxImg, 0, 0, 13, 13, Constant.TRANS_ROT90, startX + iTabWidth - 13, startY, 0); //右上角
             Tools.drawTilePic(g, (byte) 2, startX, startY + 13, 34 - 13, boxImg, 14, 0, 13, 13, Constant.TRANS_NONE);//左面
             Tools.drawTilePic(g, (byte) 2, startX + iTabWidth - 13, startY + 13, 34 - 13, boxImg, 14, 0, 13, 13, Constant.TRANS_ROT180);//右面
             Tools.drawTilePic(g, (byte) 1, startX + 13, startY, iTabWidth - 26, boxImg, 28, 0, 13, 13, Constant.TRANS_NONE);//上面
             //tab标题背景
             g.drawRegion(boxImg, 42, 0, 10, 24, Constant.TRANS_NONE, startX + 6, startY + 5, 0); //头
             g.drawRegion(boxImg, 42, 0, 10, 24, Constant.TRANS_ROT180, startX + iTabWidth - 16, startY + 5, 0); //尾
             Tools.drawTilePic(g, (byte) 1, startX + 16, startY + 5, iTabWidth - 32, boxImg, 53, 0, 10, 24, Constant.TRANS_NONE);//中间
             Tools.drawOpWord(g, this.sArray[i], this.byTabIndex == i + 1 ? true : false, (byte) 2, this.imgArray[14], startX + ((iTabWidth - Constant.FONT_SMALL.stringWidth(sArray[i])) >> 1), startY + ((34 - Constant.FONT_SMALL_HEIGHT) >> 1), 0xFFFFFF, 0x39abc6, 0x000000);
             if (i + 1 != byTabIndex) {
                 Tools.setColor(g, 0x333333);
                 g.drawLine(startX + 1, startY + 32, startX + iTabWidth - 1, startY + 32);
             }
             startX = startX + 3 + iTabWidth;
         }
        //#else
//#        //绘制公共部分的边线和中间的填充部分
//#        //左面的
//#        Tools.drawTilePic(g, (byte) 2, startX, startY + 28, 165, boxImg, 14, 0, 7, 7, Constant.TRANS_NONE);
//#        //右面的
//#        Tools.drawTilePic(g, (byte) 2, startX + 225, startY + 28, 165, boxImg, 14, 7, 7, 7, Constant.TRANS_NONE);
//#        //下面的
//#        Tools.drawTilePic(g, (byte) 1, startX + 7, startY + 193, 218, boxImg, 21, 7, 6, 7, Constant.TRANS_NONE);
//#        //底部
//#        g.drawRegion(boxImg, 0, 7, 7, 7, Constant.TRANS_NONE, startX, startY + 193, 0); //左下角
//#        g.drawRegion(boxImg, 7, 7, 7, 7, Constant.TRANS_NONE, startX + 232 - 7, startY + 193, 0); //右下角
//#        //填充中间的部分呢
//#        g.setColor(0x989898);
//#        g.fillRect(startX + 7, startY + 28, 218, 165);
//#        int iTabWidth = 76;
//#        for (byte i = 0; i < 3; i++) {
//#            g.setColor(0x989898);
//#            g.fillRect(startX + 7, startY + 7, 76 - 14, 21);
//#            //左上角
//#            g.drawRegion(boxImg, 0, 0, 7, 7, Constant.TRANS_NONE, startX, startY, 0); //左上角
//#            //右上角
//#            g.drawRegion(boxImg, 7, 0, 7, 7, Constant.TRANS_NONE, startX + iTabWidth - 7, startY, 0);//右上角
//#            //左
//#            Tools.drawTilePic(g, (byte) 2, startX, startY + 7, 21, boxImg, 14, 0, 7, 7, Constant.TRANS_NONE);
//#            //右
//#            Tools.drawTilePic(g, (byte) 2, startX + iTabWidth - 7, startY + 7, 21, boxImg, 14, 7, 7, 7, Constant.TRANS_NONE);
//#            //上
//#            Tools.drawTilePic(g, (byte) 1, startX + 7, startY, iTabWidth - 14, boxImg, 21, 0, 6, 7, Constant.TRANS_NONE);
//#            //tab标题背景
//#            g.drawRegion(boxImg, 27, 0, 5, 14, Constant.TRANS_NONE, startX + 3, startY + 7, 0); //头
//#            g.drawRegion(boxImg, 27, 0, 5, 14, Constant.TRANS_ROT180, startX + iTabWidth - 8, startY + 7, 0); //尾
//#            Tools.drawTilePic(g, (byte) 1, startX + 8, startY + 7, iTabWidth - 16, boxImg, 31, 0, 1, 14, Constant.TRANS_NONE);
//#            Tools.drawOpWord(g, this.sArray[i], this.byTabIndex == i + 1 ? true : false, (byte) 2, this.imgArray[14], startX + ((iTabWidth - Constant.FONT_SMALL.stringWidth(sArray[i])) >> 1), startY + ((28 - Constant.FONT_SMALL_HEIGHT) >> 1), 0xFFFFFF, 0x39abc6, 0x000000);
//#            if (i + 1 != byTabIndex) {
//#                Tools.setColor(g, 0x333333);
//#                g.drawLine(startX + 1, startY + 26, startX + 1 + 73, startY + 26);
//#            }
//#            startX = startX + 2 + iTabWidth;
//#        }
        //#endif
    }

    /**
     * 绘制包裹界面
     * @param g
     */
    public void drawPackage(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[2], this.imgArray[7], this.imgArray[6], this.imgArray[4], this.imgArray[5], this.sArray[0]);
         iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1);
         drawPackageBg(g, iStartX, this.iStartPointY, this.imgArray[3]);
         iStartY = this.iStartPointY + 36;
         iStartX = iStartX + 6;
         Tools.drawPackageBox(g, this.getCurrentPackage(), this.imgArray[10], this.imgArray[0], this.sArray[14], iStartX, iStartY, byCurrentPage, this.byTotalPage, null, this.imgArray[11]);
         Tools.drawMoney(g, lMoney, this.imgArray[12], this.imgArray[13], this.imgArray[10], Constant.UI_START_X + 30, Constant.UI_START_Y + 400);
         drawBottomOption(g, this.imgArray[0], iStartX, this.iStartPointY + 214 + Constant.FONT_SMALL_HEIGHT);
         //绘制选中横条
         //Yujiang
         //Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iPositionY, Constant.DRAW_WIDTH);
         //绘制物品的选中状态(最上层。防止被覆盖)
         if (this.bySelectIndex >= 2 && this.bySelectIndex <= 5) {
             if (this.shPos >= 0) {
                 if (this.shPos % 7 == 0) {
                     this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1) + 6;
                     iStartY = this.iStartPointY + 36 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 44;
                 } else {
                     this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 318) >> 1) + 6 + (this.shPos % 7) * 44;
                     iStartY = this.iStartPointY + 36 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 44;
                 }
                 this.getCurrentPackage().drawSelectStyle(g, iStartX, iStartY);
                 if (this.getCurrentPackage().checkColumn(this.shPos) == 1) {
                     if (!this.bShowMenu) {
                         Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
                     }
 //                    this.getCurrentPackage().drawGoodsName(g, this.shPos, Constant.UI_START_X + 33, this.iStartPointY + 212);
                     Tools.drawHCycleRollingParagraph(g, this.getCurrentPackage().getGoodsDesc(this.shPos), this.iGoodsDescHeight, 300, 60, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + 30, Constant.UI_START_X + 335, 0xFFFFFF, -1);
                     if (bShowMenu) {
                         Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
                     }
                 }
             }
         }
         Tools.drawSelectMask(g, (byte) 2, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_X + 325, Constant.DRAW_WIDTH);

         switch (byUiState) {
             case 4:
                 Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + 25, Constant.UI_START_Y + ((Constant.END_LINE - 120) >> 1), 310, 120, this.imgArray[3], 0x9c9c9c, this.imgArray[9], 22, 0, 21, 10, this.imgArray[9], 0, 0, 22, 10, this.sArray[7], this.sArray[8]);
                 break;
             case 6:
                 Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + 25, Constant.UI_START_Y + ((Constant.END_LINE - 120) >> 1), 310, 120, this.imgArray[3], 0x9c9c9c, this.imgArray[9], 22, 0, 21, 10, this.imgArray[9], 0, 0, 22, 10, this.sArray[7], this.sArray[10]);
                 break;
         }
        //#else
        //#if NOKIA_E72
//#         Tools.drawE72Frame(g, this.imgArray[2], this.sArray[12], this.sArray[13], sArray[0]);
        //#else
//#        Tools.drawFrame(g, this.imgArray[2], this.imgArray[1], this.sArray[12], this.sArray[13], sArray[0]);
        //#endif
//#
//#        this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1);
//#
//#        this.iStartY = this.iStartPointY;
//#        //绘制包裹栏和任务栏的背景
//#        drawPackageBg(g, this.iStartX, this.iStartY, this.imgArray[6]);
//#        //开始绘制包裹中的内容
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#        iStartY = this.iStartPointY + 29;
//#        Tools.drawPackageBox(g, this.getCurrentPackage(), this.imgArray[10], this.imgArray[0], this.sArray[14], iStartX, iStartY, byCurrentPage, this.byTotalPage, null, this.imgArray[13]);
        //#if NOKIA_E72
//#         Tools.drawMoney(g, lMoney, this.imgArray[8], this.imgArray[7], this.imgArray[10], Constant.UI_START_X + 46, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 16);
        //#else
//#        Tools.drawMoney(g, lMoney, this.imgArray[8], this.imgArray[7], this.imgArray[10], Constant.UI_START_X + 15, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 24 - Constant.FONT_SMALL_HEIGHT);
        //#endif
//#        drawBottomOption(g, this.imgArray[0], iStartX, this.iStartPointY + 179);
//#        //绘制选中横条
//#        Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, this.iPositionY, Constant.DRAW_WIDTH);
//#        //绘制物品的选中状态(最上层。防止被覆盖)
//#        if (this.bySelectIndex >= 2 && this.bySelectIndex <= 5) {
//#            if (this.shPos >= 0) {
//#                if (this.shPos % 7 == 0) {
//#                    this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#                    iStartY = this.iStartPointY + 29 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 32;
//#                } else {
//#                    this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5 + (this.shPos % 7) * 32;
//#                    iStartY = this.iStartPointY + 29 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 32;
//#                }
//#                this.getCurrentPackage().drawSelectStyle(g, iStartX, iStartY);
//#                if (this.getCurrentPackage().checkColumn(this.shPos) == 1) {
//#//                    //#if NOKIA_E72
//#                    if (!this.bShowMenu && this.byUiState != 7) {
//#                        Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
//#                    }
//#//                    Tools.setColor(g, 0xFFFFFF);
//#//                    g.drawString(this.sArray[11] + this.getCurrentPackage().getGoodsLevel(this.shPos), Constant.UI_START_X + ((Constant.DRAW_WIDTH - 229) >> 1) + 14 + Constant.FONT_SMALL.stringWidth(this.getCurrentPackage().getGoodsAlias(this.shPos)), this.iStartPointY + 158, 0);
//#//                    //#else
//#//                    this.getCurrentPackage().drawGoodsName(g, this.shPos, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 229) >> 1) + 10, this.iStartPointY + 158);
//#//                    Tools.drawHCycleRollingParagraph(g, this.getCurrentPackage().getGoodsDesc(this.shPos), this.iGoodsDescHeight, 209, 43, Constant.FONT_SMALL_HEIGHT, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 229) >> 1) + 10, this.iStartPointY + 203, 0xFFFFFF, -1);
//#//                    //#endif
//#                }
//#                if (bShowMenu) {
//#                    Goods.drawGoodsOperationMenu(g, sOpArray, this.byMenuIndex, iStartX, iStartY);
//#                }
//#            }
//#        }
//#        switch (byUiState) {
//#            case 4:
//#                Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 90) >> 1), 232, 90, this.imgArray[6], 0x989898, this.imgArray[11], 0, 0, 22, 10, this.imgArray[11], 22, 0, 21, 10, this.sArray[7], this.sArray[8]);
//#                break;
//#            case 6:
//#                Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 90) >> 1), 232, 90, this.imgArray[6], 0x989898, this.imgArray[11], 0, 0, 22, 10, this.imgArray[11], 22, 0, 21, 10, this.sArray[7], this.sArray[10]);
//#                break;
//#            case 7:
//#                if (this.shPos % 7 == 0) {
//#                    this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5;
//#                    iStartY = this.iStartPointY + 29 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 32;
//#                } else {
//#                    this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1) + 5 + +(this.shPos % 7) * 32;
//#                    iStartY = this.iStartPointY + 29 + ((this.shPos - (this.byCurrentPage - 1) * 28) / 7) * 32;
//#                }
//#                Tools.drawPriceInput(g, iStartX, iStartY, this.iArray[1], (byte) this.iArray[2], (byte) this.iArray[3], this.iArray[4] == 1 ? true : false, (byte) this.iArray[0], this.imgArray[5]);
//#                break;
//#        }
//#        //移动物品输入界面
//#        if (this.bShowNumInput) {
//#            Tools.drawInputCanvas(g, this.imgArray[4], (byte) 2, 232, 68, this.imgArray[6], this.imgArray[11], 0, 0, 22, 10, this.imgArray[11], 22, 0, 21, 10, 0x989898, this.sArray[9], 68, 18, this.shMoveNum, bShowFlash, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 232) >> 1), Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 68) >> 1));
//#        }
        //#endif
         
         
       
         if(bShowMenu)
        	 MainView.drawTouchRect(g, mPackageOperateRect);
         else
         {
        	  MainView.drawTouchRect(g, mPackageTopTouchRect);
              MainView.drawTouchRect(g, mPackagePageTouchRect);
              MainView.drawTouchRect(g, mPackageBottomTouchRect);
              MainView.drawTouchRect(g, mPackageTouchRect);
         }
         
    }

    private void makeItemsTips() {
        short w = 0;
        this.shTipsW = (short) (Constant.FONT_SMALL.stringWidth(this.getCurrentPackage().getGoodsAlias(this.shPos)));
        this.sTips = "<" + Tools.getColorReplaceLetter(Goods.getGoodsNameColor(this.getCurrentPackage().getGoodsColor(this.shPos))) + this.getCurrentPackage().getGoodsAlias(this.shPos) + ">";
        this.sTips += "|等级：" + this.getCurrentPackage().getGoodsLevel(this.shPos);
        w = (short) (Constant.FONT_SMALL.stringWidth("|等级：" + this.getCurrentPackage().getGoodsLevel(this.shPos)));
        this.shTipsW = this.shTipsW < w ? w : this.shTipsW;
        this.shTipsH = (short) ((Constant.FONT_SMALL_HEIGHT << 1) + 10);
        if (this.bSoldItems) {
            this.shTipsH += (short) (Constant.FONT_SMALL_HEIGHT);
            this.sTips += "|售价：" + Tools.moneyConvert(this.getCurrentPackage().getGoodsPrice(this.shPos));
            w = (short) (Constant.FONT_SMALL.stringWidth("|售价：" + Tools.moneyConvert(this.getCurrentPackage().getGoodsPrice(this.shPos))));
            this.shTipsW = this.shTipsW < w ? w : this.shTipsW;
        }
        if (this.shTipsW < 40) {
            this.shTipsW = 40;
        }
        this.shTipsW += 10;
    }

    private void makeEquipTips(Goods goods, short shPos) {
        if (goods == null || !goods.checkColumnHasGoods(shPos)) {
            return;
        }
        short w = 0;
        this.shTipsW = (short) (Constant.FONT_SMALL.stringWidth(goods.getGoodsAlias(this.shPos)));
        this.sTips = "<" + Tools.getColorReplaceLetter(Goods.getGoodsNameColor(goods.getGoodsColor(this.shPos))) + goods.getGoodsAlias(this.shPos) + ">";
        this.sTips += "|等级：" + goods.getGoodsLevel(this.shPos);
        w = (short) (Constant.FONT_SMALL.stringWidth("|等级：" + goods.getGoodsLevel(this.shPos)));
        this.shTipsW = this.shTipsW < w ? w : this.shTipsW;
        this.shTipsH = (short) ((Constant.FONT_SMALL_HEIGHT << 1) + 10);
        if (this.shTipsW < 40) {
            this.shTipsW = 40;
        }
        this.shTipsW += 10;
    }

    /**
     * 计算当前的道具的总页数
     */
    public void setBagTotalPage() {
        if ((MainLogic.getInstance().byGameState == Constant.GAME_UI_PACKAGE) || this.bShowBAG) {
            int iLimit = this.getCurrentPackage().getMaxColumNum();
            this.byTotalPage = (byte) (Tools.ceil(iLimit, 28));
            this.byTotalPage = (byte) Math.max(this.byTotalPage, 1);
            this.byCurrentPage = (byCurrentPage < 1 || byCurrentPage > this.byTotalPage) ? 1 : byCurrentPage;
        } else if (MainLogic.getInstance().byGameState == Constant.GAME_UI_EQUIPMENT) {
            int iLimit = this.packageGoods.getMaxColumNum();
            this.byTotalPage = (byte) Tools.ceil(iLimit, 10);
            this.byTotalPage = (byte) Math.max(1, this.byTotalPage);
            this.setEquipPos();
            this.byCurrentPage = (byCurrentPage < 1 || byCurrentPage > this.byTotalPage) ? 1 : byCurrentPage;
        } else {
            this.byTotalPage = 1;
        }
    }

    /**
     * 从服务器获得物品的简单描述
     */
    private void getGoodsDescFromNet() {
        if (this.byTabIndex == 3 || this.getCurrentPackage() == null || bWaitMSGBack || System.currentTimeMillis() - this.lastSendDescTime < 1000) {
            return;
        }
        if (this.getCurrentPackage().checkColumnHasGoods(this.shPos) && !this.getCurrentPackage().isGetGoodsDesc(this.shPos)) {
            this.bWaitMSGBack = true;
            this.shGetNetDescPos = this.shPos;
            this.byGetNetDescTabIndex = this.byTabIndex;
            GameBean.STR_DESC_CDM_GOODS_KEY = this.getCurrentPackage().getGoodsKey(this.shPos);
            MainLogic.getInstance().send(Constant.MSG_NET_CMD_CHECK_STORE_DESC, Constant.SOCKET_MSG_TYPE_LOGIC);
//            this.getCurrentPackage().sendGoodsOperationMSG(this.shPos, Constant.ITEM_OPERATION_TYPE_CHECK_DESC);
            this.lastSendDescTime = System.currentTimeMillis();
        }
    }


    /*
     * 删除包裹或是任务包裹中的物品（UI界面的删除）
     */
    public void deleteGoods(short columnIndex) {
        this.getCurrentPackage().deleteGoods(columnIndex);

    }

    /**
     * 设置背包物品的描述
     */
    public void setGoodsDescFromNet(String desc) {
        if (this.getCurrentPackage() == null) {
            return;
        }
        this.getCurrentPackage().setGoodsDesc(this.shGetNetDescPos, desc, true);
        if (this.shGetNetDescPos == this.shPos) {
            Tools.rollIndex = 0;
            Tools.lastUpdateTime = System.currentTimeMillis();
            this.iGoodsDescHeight = Tools.getParagraphHeight(this.getCurrentPackage().getGoodsDesc(this.shPos), 209, 16);
        }
    }

    /**
     * 绘制包裹栏底部的内容
     * @param g
     * @param startX
     * @param startY
     */
    private void drawBottomOption(Graphics g, Image arrow, int startX, int startY) {
        //#if NOKIA_S60V5
         int byGap = 3;
        //#else
//#        int byGap = 1;
        //#endif
        if (!this.bSoldItems) {
            if (this.bShowBAG) {
                return;
            }
            Tools.drawArrow(g, arrow, (byte) 2, Constant.UI_START_X + (Constant.DRAW_WIDTH - 5 >> 1), startY + 2);
            if (bySelectIndex == 7) {
                Tools.drawShadowString(g, (byte) 1, this.sArray[3], startX, startY, bySubSelectIndex == 1 ? 0x00CCFF : 0xFFFFFF, 0x000000);
                Tools.drawShadowString(g, (byte) 1, this.sArray[4], startX + (Goods.byItemH + byGap) * 7 - byGap, startY, bySubSelectIndex == 2 ? 0x00CCFF : 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
            } else {
                //查看元宝
                Tools.drawShadowString(g, (byte) 1, this.sArray[3], startX, startY, 0xFFFFFF, 0x000000);
                Tools.drawShadowString(g, (byte) 1, this.sArray[4], startX + (Goods.byItemH + byGap) * 7 - byGap, startY, 0xFFFFFF, 0x000000, g.RIGHT | g.TOP);
            }
        }
    }

    /**
     * 清除包裹界面的资源
     */
    public void clearPackage() {
        if (!this.bShowBAG) {
            ResManager.clearRes(Constant.RES_PUBLIC_TEMP);
        }
        this.bySortItem = -1;
        this.imgArray = null;
        this.petPackageGoods = null;
        this.packageGoods = null;
        this.taskPackageGoods = null;
        this.equipPackageGoods = null;
        this.iArray = null;
        this.sArray = null;
        this.sOpArray = null;
        this.bShowBAG = false;
        this.bSendShowBag = false;
        this.sPetDetail = null;
        this.shPos = -1;
        this.bGetDataFromNet = null;
        this.sTips = null;
    }

    /****************************************************装备界面*****************************************************************************************************************************************/
    /**
     * 装备栏界面资源初始化
     */
    public void initEquip() {
//        this.equipPackageGoods = new Goods();
//        this.equipPackageGoods.init((short) 10, Constant.ITEM_COLUMN_TYPE_EQUIP);
//        this.equipPackageGoods.addGoods((short) 0, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");
//        this.packageGoods = new Goods();
//        this.packageGoods.init((short) 11, Constant.ITEM_COLUMN_TYPE_COMMON);
//        this.packageGoods.addGoods((short) 0, true, -1, (short) -1, "据钴棒据钴", (short) 1, 1196, (byte) -1, (byte) 5, (byte) -1, (byte) -1, (byte) -1, null, (short) 10, 5, (byte) 99, "10031");

        bySelectIndex = 1;
        bShowMenu = false;
        bySubSelectIndex = 1;
        byMenuIndex = 0;
        this.bySubSelectIndex = 1;
        this.shPos = 0;
        //界面中的位置的统一配置
        this.sArray = new String[]{"我的装备", "现有装备", "背包装备", "提示", "您确定要丢弃该物品么"};
        sEquipPlaceName = Goods.getEquipPlaceName();
        //#if NOKIA_S60V5
         this.iStartPointY = Constant.UI_START_Y + 125;
         iPositionY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 9;
         imgArray = new Image[16];
         //箭头图片
         this.imgArray[0] = ResManager.createImage(90000041);
         //蓝色光片
         this.imgArray[1] = Tools.makeBlueMask();
         //光柱图片
         this.imgArray[2] = Tools.createPicFromGrayscale(ResManager.createImage(90000046), 0xFFFFFF);
         //背景图片
         this.imgArray[3] = ResManager.createImage(90000017);
         //白色的确定取消图片
         this.imgArray[4] = ResManager.createImage(90000044);
         //大数字图片
         this.imgArray[5] = ResManager.createImage(90000047);
         //文字图片
         this.imgArray[6] = ResManager.createImage(90000043);
         //圆角图片tishi.png
         this.imgArray[7] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
         this.imgArray[8] = ResManager.createImage(90000084);
         this.imgArray[9] = ResManager.createImage(90000085);
         this.imgArray[10] = ResManager.createImage(90000086);
        //#else
        //#if NOKIA_E72
//#         this.iStartPointY = Constant.UI_START_Y + 21;
        //#else
//#        this.iStartPointY = Constant.UI_START_Y + 82;
        //#endif
        //#if NOKIA_E72
//#         iPositionY = this.iStartPointY + 10;
        //#else
//#        iPositionY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 9;
        //#endif
//#        imgArray = new Image[8];
//#        //箭头图片
//#        this.imgArray[0] = ResManager.createImage(90000041);
//#        //蓝色光片
//#        this.imgArray[1] = Tools.makeBlueMask();
//#        //光柱图片
//#        this.imgArray[2] = Tools.createPicFromGrayscale(ResManager.createImage(90000046), 0xFFFFFF);
        //#if NOKIA_S40V3  || MOTO || K790
        //#elif NORMAL_240_400
//# //        imgArray[3] = ResManager.createImage(90000017);
//# //        imgArray[3] = Tools.ZoomImage(imgArray[3], Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
        //#else
//#        //背景图片
//#        this.imgArray[3] = ResManager.createImage(90000017);
        //#endif
//#
//#        //白色的确定取消图片 
//#        this.imgArray[4] = ResManager.createImage(90000044);
//#        //大数字图片
//#        this.imgArray[5] = ResManager.createImage(90000047);
//#        //文字图片
//#        this.imgArray[6] = ResManager.createImage(90000043);
//#        //圆角图片tishi.png
//#        this.imgArray[7] = Tools.makeTransparent(ResManager.createImage(90000051), 255);
        //#endif
    }

    /**
     * 更新装备栏逻辑
     */
    public void updateEquip() {
        if (!GameBean.b_WAIT_NET_MSG_BACK) {
            switch (this.byUiState) {
                case 0:
                    if (!bKeypressLock) {
                        if (!bShowMenu) {
                            if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                if (this.bySelectIndex > 1) {
                                    this.bySelectIndex -= 1;
                                    this.byState = (byte) 1;
                                    this.bKeypressLock = true;
                                    //#if NOKIA_S60V5
                                     switch (this.bySelectIndex) {
                                         case 1:
                                             this.bySubSelectIndex = 1;
                                             this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 9, 2, 50, 3};
                                             break;
                                         case 2:
                                             this.bySubSelectIndex = 6;
                                             this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 52, 2, 50, 3};
                                             break;
                                         case 3:
                                             this.bySubSelectIndex = 1;
                                             this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 140, 2, 50, 3};
                                             break;
                                         case 4:
                                             this.bySubSelectIndex = 6;
                                             this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 184, 2, 50, 3};
                                             break;
                                     }
                                    //#else
                                    //#if NOKIA_E72
//#                                     switch (this.bySelectIndex) {
//#                                         case 1:
//#                                             this.bySubSelectIndex = 1;
//#                                             this.iArray = new int[]{2, 1, this.iStartPointY + 10, 2, 50, 3};
//#                                             break;
//#                                         case 2:
//#                                             this.bySubSelectIndex = 6;
//#                                             this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 39, 2, 50, 3};
//#                                             break;
//#                                         case 3:
//#                                             this.bySubSelectIndex = 1;
//#                                             this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 100, 2, 50, 3};
//#                                             break;
//#                                         case 4:
//#                                             this.bySubSelectIndex = 6;
//#                                             this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 135, 2, 50, 3};
//#                                             break;
//#                                     }
                                    //#else
//#                                    switch (this.bySelectIndex) {
//#                                        case 1:
//#                                            this.bySubSelectIndex = 1;
//#                                            this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 9, 2, 50, 3};
//#                                            break;
//#                                        case 2:
//#                                            this.bySubSelectIndex = 6;
//#                                            this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 39, 2, 50, 3};
//#                                            break;
//#                                        case 3:
//#                                            this.bySubSelectIndex = 1;
//#                                            this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 100, 2, 50, 3};
//#                                            break;
//#                                        case 4:
//#                                            this.bySubSelectIndex = 6;
//#                                            this.iArray = new int[]{2, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 135, 2, 50, 3};
//#                                            break;
//#                                    }
                                    //#endif
//#
                                    //#endif
                                    this.setEquipPos();
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                if (this.bySelectIndex < 6) {
                                    this.bySelectIndex += 1;
                                    this.byState = (byte) 2;
                                    this.bKeypressLock = true;
                                    //#if NOKIA_S60V5
                                     switch (this.bySelectIndex) {
                                         case 2:
                                             this.bySubSelectIndex = 6;
                                             this.iArray = new int[]{1, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 52, 2, 50, 3};
                                             break;
                                         case 3:
                                             this.bySubSelectIndex = 1;
                                             this.iArray = new int[]{1, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 140, 2, 50, 3};
                                             break;
                                         case 4:
                                             this.bySubSelectIndex = 6;
                                             this.iArray = new int[]{1, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 184, 2, 50, 3};
                                             break;
                                         case 5:
                                             this.bySubSelectIndex = 1;
                                             this.iArray = new int[]{1, 1, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 10, 2, 50, 3};
                                             break;
                                     }
                                    //#else
                                    //#if NOKIA_E72
//#                                     switch (this.bySelectIndex) {
//#                                         case 2:
//#                                             this.bySubSelectIndex = 6;
//#                                             this.iArray = new int[]{1, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 35, 2, 50, 3};
//#                                             break;
//#                                         case 3:
//#                                             this.bySubSelectIndex = 1;
//#                                             this.iArray = new int[]{1, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 100, 2, 50, 3};
//#                                             break;
//#                                         case 4:
//#                                             this.bySubSelectIndex = 6;
//#                                             this.iArray = new int[]{1, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 135, 2, 50, 3};
//#                                             break;
//#                                         case 5:
//#                                             this.bySubSelectIndex = 1;
//#                                             this.iArray = new int[]{1, 1, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 3, 2, 50, 3};
//#                                             break;
//#                                     }
                                    //#else
//#                                    switch (this.bySelectIndex) {
//#                                        case 2:
//#                                            this.bySubSelectIndex = 6;
//#                                            this.iArray = new int[]{1, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 35, 2, 50, 3};
//#                                            break;
//#                                        case 3:
//#                                            this.bySubSelectIndex = 1;
//#                                            this.iArray = new int[]{1, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 100, 2, 50, 3};
//#                                            break;
//#                                        case 4:
//#                                            this.bySubSelectIndex = 6;
//#                                            this.iArray = new int[]{1, 1, this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 135, 2, 50, 3};
//#                                            break;
//#                                        case 5:
//#                                            this.bySubSelectIndex = 1;
//#                                            this.iArray = new int[]{1, 1, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 3, 2, 50, 3};
//#                                            break;
//#                                    }
                                    //#endif
                                    //#endif
                                    this.setEquipPos();
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_LEFT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                    case 2:
                                        this.checkEquipSubSelectIndex(Constant.ITEM_COLUMN_TYPE_EQUIP, (byte) 0, bySelectIndex);
                                        break;
                                    case 3:
                                    case 4:
                                        this.checkEquipSubSelectIndex(Constant.ITEM_COLUMN_TYPE_COMMON, (byte) 0, (byte) (bySelectIndex - 2));
                                        break;
                                    case 5:
                                        if (this.byCurrentPage > 1) {
                                            this.byCurrentPage = (byte) (this.byCurrentPage - 1);
                                            this.bySubSelectIndex = 1;
                                            this.setEquipPos();
                                        }
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_RIGHT, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                    case 2:
                                        this.checkEquipSubSelectIndex(Constant.ITEM_COLUMN_TYPE_EQUIP, (byte) 1, bySelectIndex);
                                        break;
                                    case 3:
                                    case 4:
                                        this.checkEquipSubSelectIndex(Constant.ITEM_COLUMN_TYPE_EQUIP, (byte) 1, (byte) (bySelectIndex - 2));
                                        break;
                                    case 5:
                                        if (this.byCurrentPage < this.byTotalPage) {
                                            this.byCurrentPage = (byte) (this.byCurrentPage + 1);
                                            this.bySubSelectIndex = 1;
                                            this.setEquipPos();
                                        }
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false)) {
                                switch (this.bySelectIndex) {
                                    case 1:
                                    case 2:
                                        if (this.shPos < this.equipPackageGoods.getMaxColumNum() && this.equipPackageGoods.checkColumnHasGoods(this.shPos)) {
                                            this.bShowMenu = true;
                                            this.byMenuIndex = 0;
                                            //包裹栏中物品的操作方法
                                            this.sOpArray = Goods.getGoodsOperation(Constant.ITEM_COLUMN_TYPE_EQUIP, Goods.getEquipmentType(this.equipPackageGoods.getGoodsEquipPlace(this.shPos)));
                                        }
                                        break;
                                    case 3:
                                    case 4:
                                        if (this.shPos < this.packageGoods.getMaxColumNum() && this.packageGoods.checkColumnHasGoods(this.shPos)) {
                                            this.bShowMenu = true;
                                            this.byMenuIndex = 0;
                                            //包裹栏中物品的操作方法
                                            this.sOpArray = Goods.getGoodsOperation(Constant.ITEM_COLUMN_TYPE_EQUIP_PACKAGE, Goods.getEquipmentType(this.packageGoods.getGoodsEquipPlace(this.shPos)));
                                        }
                                        break;
                                }
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                //跳转到漫游界面
                                if (GameBean.BY_PRE_GAME_UI_STATE == Constant.GAME_UI_PLAYER_TOP) {
                                    //#if NOKIA_S60V5
                                     Tools.openRoamMenu(false, (byte) 1, (byte) 0, 11);
                                    //#else
//#                                    Tools.openRoamMenu(false, (byte) 2, (byte) 0, 1);
                                    //#endif
                                } else {
                                    Tools.openRoamMenu(false, (byte) 1, (byte) 2, 2);
                                }
                            }
                        } else {
                            if (this.bySelectIndex > 4) {
                                this.bShowMenu = false;
                                return;
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                                this.bShowMenu = false;
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_UP, false)) {
                                this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 0);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_DOWN, false)) {
                                this.byMenuIndex = Tools.updatePopMenu((byte) this.sOpArray.length, this.byMenuIndex, (byte) 1);
                            } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false)) {
                                this.bShowMenu = false;
                                byte opType = -1;
                                if (bySelectIndex == 1 || bySelectIndex == 2) {
                                    GameBean.b_WAIT_NET_MSG_BACK = true;
                                    opType = this.equipPackageGoods.sendGoodsOperationMSG((short) (this.bySubSelectIndex - 1), this.sOpArray, this.byMenuIndex);
                                    //查看，对比，装备，卸载
                                } else if (bySelectIndex == 3 || bySelectIndex == 4) {
                                    opType = packageGoods.getOperationType(this.sOpArray, this.byMenuIndex);
                                    if (opType == Constant.ITEM_OPERATION_TYPE_DELETE) {
                                        this.byUiState = 6;
                                        this.byPopUpState = 1;
                                        return;
                                    } else {
                                        GameBean.b_WAIT_NET_MSG_BACK = true;
                                        //查看，对比，装备，卸载
                                        this.byPopUpState = 1;
                                        this.packageGoods.sendGoodsOperationMSG((short) ((this.byCurrentPage - 1) * 10 + this.bySubSelectIndex - 1), opType);
                                    }
                                }
                            }
                        }
                        this.bShowFlash = this.bShowFlash ? false : true;
                    } else {
                        if (this.byState == 1 || this.byState == 2) {
                            iPositionY = Tools.updateLinePos(this.iArray, iPositionY);
                            if (this.iArray == null || this.iArray[1] == 0) {
                                this.byState = 0;
                                this.bKeypressLock = false;
                            }
                        }
                        MainCanvas.clearInput();
                    }
                    break;
                case 6:
                    //删除物品
                    if (this.byPopUpState >= 4) {
                        if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_POSITIVE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_FIRE, false) || MainCanvas.keyPressedLogic(Constant.GAME_KEY_5, false)) {
                            //发送消息
                            this.byUiState = 0;
                            this.bKeypressLock = false;
                            //发送删除指令信息
                            GameBean.b_WAIT_NET_MSG_BACK = true;
                            this.packageGoods.sendGoodsOperationMSG(this.shPos, Constant.ITEM_OPERATION_TYPE_DELETE);
                            break;
                        } else if (MainCanvas.keyPressedLogic(Constant.GAME_KEY_NEGATIVE, false)) {
                            this.byUiState = 0;
                        }
                    } else {
                        this.byPopUpState++;
                    }
                    break;
            }
        }
    }

    /**
     * 绘制装备界面
     * @param g
     */
    public void drawEquip(Graphics g) {
        //#if NOKIA_S60V5
         Tools.drawS60V5Frame(g, this.imgArray[3], this.imgArray[8], this.imgArray[9], this.imgArray[10], this.imgArray[6], this.sArray[0]);
         g.drawImage(this.imgArray[2], Constant.UI_START_X + ((Constant.DRAW_WIDTH - 154) >> 1), Constant.UI_START_Y + 41, 0);
         g.drawRegion(this.imgArray[2], 0, 0, 77, 170, Constant.TRANS_MIRROR, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 154) >> 1) + 77, Constant.UI_START_Y + 41, 0);
         //人物动画
         MainLogic.getInstance().gamePlayer.showOnlyAni(g, Constant.UI_START_X + (Constant.DRAW_WIDTH >> 1), this.iStartPointY + Constant.FONT_SMALL_HEIGHT, Constant.PLAYER_STATE_STAND, Constant.PLAYER_DIRECTION_DOWN);
            iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byTotalPage, byCurrentPage)) >> 1);
         //绘制翻页
         Tools.drawPage(g, this.byTotalPage, byCurrentPage, this.imgArray[5], this.imgArray[0], iStartX, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 22);
    iStartX = Constant.UI_START_X + 20;
         iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 84;
         //绘制包裹装备的道具背景
         g.setColor(0x9c9c9c);
         g.fillRect(iStartX + 13, iStartY + 13, 107, 34);
         g.fillRect(iStartX + 13, iStartY + 47, 294, 91);
         //绘制角
         g.drawRegion(imgArray[7], 0, 0, 13, 13, Constant.TRANS_NONE, iStartX, iStartY, 0); //左上角
         g.drawRegion(imgArray[7], 0, 0, 13, 13, Constant.TRANS_ROT90, iStartX + 120 - 13, iStartY, 0); //右上角
         g.drawRegion(imgArray[7], 0, 0, 13, 13, Constant.TRANS_ROT90, iStartX + 320 - 13, iStartY + 34, 0); //右上角
         //绘制背包道具的背景
         Tools.drawTilePic(g, (byte) 1, iStartX + 13, iStartY, 120 - 26, imgArray[7], 28, 0, 13, 13, Constant.TRANS_NONE);//上面
         Tools.drawTilePic(g, (byte) 2, iStartX + 120 - 13, iStartY + 13, 34 - 13, imgArray[7], 14, 0, 13, 13, Constant.TRANS_ROT180);//右面小短线
         Tools.drawTilePic(g, (byte) 1, iStartX + +120, iStartY + 34, 200 - 13, imgArray[7], 28, 0, 13, 13, Constant.TRANS_NONE);//上面长线
         Tools.drawTilePic(g, (byte) 2, iStartX + 320 - 13, iStartY + 34 + 13, 125 - 34, imgArray[7], 14, 0, 13, 13, Constant.TRANS_ROT180);//右面长线
         Tools.drawTilePic(g, (byte) 2, iStartX, iStartY + 13, 125, imgArray[7], 14, 0, 13, 13, Constant.TRANS_NONE);//左面

         //包裹中装备
         Tools.drawShadowString(g, (byte) 1, this.sArray[2], iStartX + ((120 - Constant.FONT_SMALL.stringWidth(this.sArray[1])) >> 1), iStartY + ((34 - Constant.FONT_SMALL_HEIGHT) >> 1), 0x00CCFF, 0x000000);
         //绘制选中状态
         if (this.bySelectIndex < 5) {
             Tools.drawGapSlectMask(g, this.imgArray[1], this.imgArray[0], this.bShowFlash, 22, Constant.UI_START_X, iPositionY, Constant.DRAW_WIDTH);
         } else {
             Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, iPositionY, Constant.DRAW_WIDTH);
         }

         //身上的武器
         Tools.drawShadowString(g, (byte) 1, this.sArray[1], Constant.UI_START_X + 26, this.iStartPointY, 0x00CCFF, 0x000000);
         iStartX = Constant.UI_START_X + 25;
         iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 1;
         for (short i = 0; i < Constant.PLAYER_WEAR_EQUIP_NUM; i++) {
             if (i == 5) {
                 iStartX = Constant.UI_START_X + 25;
                 iStartY = iStartY + 42 + Constant.FONT_SMALL_HEIGHT;
             }
             //绘制装备
             this.equipPackageGoods.drawEquipment(g, iStartX, iStartY, i);
             Tools.drawShadowString(g, (byte) 1, this.sEquipPlaceName[i], iStartX + ((41 - Constant.FONT_SMALL.stringWidth(this.sEquipPlaceName[i])) >> 1), iStartY + 41, 0xFFFFFF, 0x000000);
             iStartX += 67;
         }

         //包裹装备栏目
         iStartX = Constant.UI_START_X + 26;
         iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 129;
         //绘制包裹中武器和装备
         for (short i = 0; i < 10; i++) {
             if (i == 5) {
                 iStartX = Constant.UI_START_X + 26;
                 iStartY += 45;
             }
             //格子的索引
             //绘制包裹中的装备
             this.packageGoods.drawGoods(g, iStartX, iStartY, (short) ((this.byCurrentPage - 1) * 10 + i));
             iStartX += 67;
         }

         //绘制装备的名称
         if ((this.bySelectIndex == 1 || this.bySelectIndex == 2) && this.shPos < equipPackageGoods.getMaxColumNum()) {
             //绘制选中状态
             if (this.bySelectIndex == 1) {
                 this.iStartX = Constant.UI_START_X + 26 + (this.bySubSelectIndex - 1) * 67;
                 iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 1;
             } else if (this.bySelectIndex == 2) {
                 this.iStartX = Constant.UI_START_X + 26 + (this.bySubSelectIndex - 6) * 67;
                 iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 42 + Constant.FONT_SMALL_HEIGHT;
             }
             equipPackageGoods.drawSelectStyle(g, iStartX, iStartY);
             if (equipPackageGoods.checkColumnHasGoods(this.shPos)) {
                 Goods.drawGoodsName(g, equipPackageGoods.getGoodsColor(this.shPos), equipPackageGoods.getGoodsAlias(this.shPos), Constant.UI_START_X + 320 - Constant.FONT_SMALL.stringWidth(equipPackageGoods.getGoodsAlias(this.shPos)), this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 84 + 33);
                 if (this.bShowMenu) {
                     Goods.drawGoodsOperationMenu(g, this.sOpArray, this.byMenuIndex, iStartX, iStartY);
                 } else {
                     Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
                 }
             }
         } else if ((this.bySelectIndex == 3 || this.bySelectIndex == 4) && this.shPos < packageGoods.getMaxColumNum()) {
             if (this.bySelectIndex == 3) {
                 this.iStartX = Constant.UI_START_X + 26 + (this.bySubSelectIndex - 1) * 67;
                 iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 84 + 45;
             } else if (this.bySelectIndex == 4) {
                 this.iStartX = Constant.UI_START_X + 26 + (this.bySubSelectIndex - 6) * 67;
                 iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 174;
             }
             packageGoods.drawSelectStyle(g, iStartX, iStartY);
             if (packageGoods.checkColumnHasGoods(this.shPos)) {
                 if (this.bShowMenu) {
                     Goods.drawGoodsOperationMenu(g, this.sOpArray, this.byMenuIndex, iStartX, iStartY);
                 } else {
                     Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
                 }
             }
         }
         MainView.drawTouchRect(g, mpackdir);
         if (this.bShowMenu) {
        	 MainView.drawTouchRect(g, mpackmenu);
         } else {
        	 MainView.drawTouchRect(g, mpack);
         }

         switch (this.byUiState) {
             case 6:
                 //"删除提示","您确定要丢弃该物品么"
                 Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + 25, Constant.UI_START_Y + ((Constant.END_LINE - 120) >> 1), 310, 120, this.imgArray[7], 0x9c9c9c, this.imgArray[4], 22, 0, 21, 10, this.imgArray[4], 0, 0, 22, 10, this.sArray[3], this.sArray[4]);
                 break;

         }
        //#else
//#        //光柱图片
        //#if NOKIA_E72
        //#else
//#        g.drawImage(this.imgArray[2], Constant.UI_START_X + ((Constant.DRAW_WIDTH - 154) >> 1), Constant.UI_START_Y, 0);
//#        g.drawRegion(this.imgArray[2], 0, 0, 77, 170, Constant.TRANS_MIRROR, Constant.UI_START_X + ((Constant.DRAW_WIDTH - 154) >> 1) + 77, Constant.UI_START_Y, 0);
        //#endif
        //#if NOKIA_S40V3 || NORMAL_240_400  || MOTO || K790
//#         g.setColor(0x000000);
//#         g.fillRect(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, Constant.DRAW_HEIGHT);
        //#else
//#        g.drawImage(this.imgArray[3], Constant.UI_START_X, Constant.UI_START_Y, 0);
        //#endif
//#        //背景
        //#if NOKIA_E72
//#         g.drawRegion(this.imgArray[6], 0, 0, 24, 12, Constant.TRANS_NONE, Constant.UI_START_X + 10, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 16, 0);
//#         g.drawRegion(this.imgArray[6], 49, 0, 23, 12, Constant.TRANS_NONE, Constant.UI_START_X + Constant.DRAW_WIDTH - 33, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 16, 0);
        //#else
//#        Tools.drawSelectMask(g, (byte) 2, this.imgArray[1], Constant.UI_START_X, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 22, Constant.DRAW_WIDTH, this.imgArray[0], this.imgArray[6], 0, 0, 24, 12, this.imgArray[6], 49, 0, 23, 12);
        //#endif
//#        //标题背景
//#        Tools.setColor(g, 0x393939);
//#        g.fillRect(Constant.UI_START_X, Constant.UI_START_Y, Constant.DRAW_WIDTH, 21);
//#        //标题
//#        Tools.drawShadowString(g, (byte) 1, sArray[0], Constant.UI_START_X + ((Constant.DRAW_WIDTH - Constant.FONT_SMALL.stringWidth(this.sArray[0])) >> 1), Constant.UI_START_Y + ((21 - Constant.FONT_SMALL_HEIGHT) >> 1), 0xFFFFFF, 0x000000);
//#        //人物动画
        //#if NOKIA_E72
        //#else
//#        MainLogic.getInstance().gamePlayer.showOnlyAni(g, Constant.UI_START_X + 114, Constant.UI_START_Y + 91, Constant.PLAYER_STATE_STAND, Constant.PLAYER_DIRECTION_DOWN);
        //#endif
//#        //身上的武器
        //#if NOKIA_E72
//#         Tools.drawShadowString(g, (byte) 1, this.sArray[1], Constant.UI_START_X + 5, this.iStartPointY, 0x00CCFF, 0x000000);
        //#else
//#        Tools.drawShadowString(g, (byte) 1, this.sArray[1], Constant.UI_START_X + ((Constant.DRAW_WIDTH - 170) >> 1), this.iStartPointY, 0x00CCFF, 0x000000);
        //#endif
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - Tools.getPageStrWidth(this.byTotalPage, byCurrentPage)) >> 1);
//#        //绘制翻页
        //#if NOKIA_E72
//#         Tools.drawPage(g, this.byTotalPage, byCurrentPage, this.imgArray[5], this.imgArray[0], iStartX, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 10);
        //#else
//#        Tools.drawPage(g, this.byTotalPage, byCurrentPage, this.imgArray[5], this.imgArray[0], iStartX, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 14);
        //#endif
//#        //绘制页头内容F
//#        //打开包裹
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 185) >> 1);
        //#if NOKIA_E72
//#         iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 65;
        //#else
//#        iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 65;
        //#endif
//#        //绘制包裹装备的道具背景
//#        g.setColor(0x989898);
//#        g.fillRect(iStartX + 7, iStartY + 7, 78, 87);
//#        g.fillRect(iStartX + 85, iStartY + 28, 103, 66);
//#        //绘制角
//#        g.drawRegion(imgArray[7], 0, 0, 7, 7, Constant.TRANS_NONE, iStartX, iStartY, 0); //左上角
//#        g.drawRegion(imgArray[7], 7, 0, 7, 7, Constant.TRANS_NONE, iStartX + 85 - 7, iStartY, 0);//右上角
//#        g.drawRegion(imgArray[7], 7, 0, 7, 7, Constant.TRANS_NONE, iStartX + 195 - 7, iStartY + 21, 0);//右上角
//#        //绘制背包道具的背景
//#        Tools.drawTilePic(g, (byte) 1, iStartX + 7, iStartY, 71, imgArray[7], 21, 0, 6, 7, Constant.TRANS_NONE);//上面
//#        Tools.drawTilePic(g, (byte) 2, iStartX + 85 - 7, iStartY + 7, 14, imgArray[7], 14, 7, 7, 7, Constant.TRANS_NONE);//右面小短线
//#        Tools.drawTilePic(g, (byte) 1, iStartX + 85, iStartY + 21, 103, imgArray[7], 21, 0, 6, 7, Constant.TRANS_NONE);//上面长线
//#        Tools.drawTilePic(g, (byte) 2, iStartX + 188, iStartY + 28, 66, imgArray[7], 14, 7, 7, 7, Constant.TRANS_NONE);//右面长线
//#        Tools.drawTilePic(g, (byte) 2, iStartX, iStartY + 7, 87, imgArray[7], 14, 0, 7, 7, Constant.TRANS_NONE);//左面
//#        //现有装备
//#        Tools.drawShadowString(g, (byte) 1, this.sArray[2], iStartX + ((78 - Constant.FONT_SMALL.stringWidth(this.sArray[1])) >> 1), iStartY + ((27 - Constant.FONT_SMALL_HEIGHT) >> 1), 0x00CCFF, 0x000000);
//#        //绘制选中状态
//#        if (this.bySelectIndex < 5) {
//#            Tools.drawGapSlectMask(g, this.imgArray[1], this.imgArray[0], this.bShowFlash, 17, Constant.UI_START_X, iPositionY, Constant.DRAW_WIDTH);
//#        } else {
//#            Tools.drawSelectMask(g, (byte) 1, this.imgArray[1], Constant.UI_START_X, iPositionY, Constant.DRAW_WIDTH);
//#        }
//#        //现有的装备
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 170) >> 1);
        //#if NOKIA_E72
//#         iStartY = this.iStartPointY + 1;
        //#else
//#        iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 1;
        //#endif
//#        for (short i = 0; i < Constant.PLAYER_WEAR_EQUIP_NUM; i++) {
//#            if (i == 5) {
//#                iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 170) >> 1);
//#                iStartY = iStartY + 30 + Constant.FONT_SMALL_HEIGHT;
//#            }
//#            //绘制装备//Image bg, Image numericPic, Image bindPic,
//#            this.equipPackageGoods.drawEquipment(g, iStartX, iStartY, i);
//#            Tools.drawShadowString(g, (byte) 1, this.sEquipPlaceName[i], iStartX + ((30 - Constant.FONT_SMALL.stringWidth(this.sEquipPlaceName[i])) >> 1), iStartY + 30, 0xFFFFFF, 0x000000);
//#            iStartX += 37;
//#        }
//#
//#        //包裹装备栏目
//#        iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 195) >> 1) + 13;
        //#if NOKIA_E72
//#         iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 65 + 27;
        //#else
//#        iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 65 + 27;
        //#endif
//#        //绘制包裹中武器和装备
//#        for (short i = 0; i < 10; i++) {
//#            if (i == 5) {
//#                iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 195) >> 1) + 13;
//#                iStartY += 35;
//#            }
//#            //格子的索引
//#            //绘制包裹中的装备
//#            this.packageGoods.drawGoods(g, iStartX, iStartY, (short) ((this.byCurrentPage - 1) * 10 + i));
//#            iStartX += 37;
//#        }
//#
//#        //绘制装备的名称
//#        if ((this.bySelectIndex == 1 || this.bySelectIndex == 2) && this.shPos < equipPackageGoods.getMaxColumNum()) {
//#            //绘制选中状态
//#            if (this.bySelectIndex == 1) {
//#                this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 170) >> 1) + this.shPos * 37;
//#                iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 1;
                //#if NOKIA_E72
//#                 iStartY = this.iStartPointY + 1;
                //#else
//#                iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 1;
                //#endif
//#            } else if (this.bySelectIndex == 2) {
//#                this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 170) >> 1) + (this.shPos - 5) * 37;
                //#if NOKIA_E72
//#                 iStartY = this.iStartPointY + 31 + Constant.FONT_SMALL_HEIGHT;
                //#else
//#                iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT + 31 + Constant.FONT_SMALL_HEIGHT;
                //#endif
//#            }
//#            equipPackageGoods.drawSelectStyle(g, iStartX, iStartY);
//#            if (equipPackageGoods.checkColumnHasGoods(this.shPos)) {
                //#if NOKIA_E72
//#                 Goods.drawGoodsName(g, equipPackageGoods.getGoodsColor(this.shPos), equipPackageGoods.getGoodsAlias(this.shPos), Constant.UI_START_X + ((Constant.DRAW_WIDTH - 195) >> 1) + 195 - Constant.FONT_SMALL.stringWidth(equipPackageGoods.getGoodsAlias(this.shPos)), this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 68);
                //#else
//#                Goods.drawGoodsName(g, equipPackageGoods.getGoodsColor(this.shPos), equipPackageGoods.getGoodsAlias(this.shPos), Constant.UI_START_X + ((Constant.DRAW_WIDTH - 195) >> 1) + 195 - Constant.FONT_SMALL.stringWidth(equipPackageGoods.getGoodsAlias(this.shPos)), this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 68);
                //#endif
//#                if (this.bShowMenu) {
//#                    Goods.drawGoodsOperationMenu(g, this.sOpArray, this.byMenuIndex, iStartX, iStartY);
//#                } else {
//#                    Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsW);
//#                }
//#            }
//#        } else if ((this.bySelectIndex == 3 || this.bySelectIndex == 4) && this.shPos < packageGoods.getMaxColumNum()) {
//#            if (this.bySelectIndex == 3) {
//#                this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 195) >> 1) + 13 + (this.bySubSelectIndex - 1) * 37;
                //#if NOKIA_E72
//#                 iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 93;
                //#else
//#                iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 93;
                //#endif
//#            } else if (this.bySelectIndex == 4) {
//#                this.iStartX = Constant.UI_START_X + ((Constant.DRAW_WIDTH - 170) >> 1) + (this.bySubSelectIndex - 6) * 37;
                //#if NOKIA_E72
//#                 iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 128;
                //#else
//#                iStartY = this.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 128;
                //#endif
//#
//#            }
//#            packageGoods.drawSelectStyle(g, iStartX - 1, iStartY - 1);
//#            if (packageGoods.checkColumnHasGoods(this.shPos)) {
//#                if (this.bShowMenu) {
//#                    Goods.drawGoodsOperationMenu(g, this.sOpArray, this.byMenuIndex, iStartX, iStartY);
//#                } else {
//#                    Tools.drawItemsPop(g, sTips, iStartX, iStartY, this.shTipsW, this.shTipsH);
//#                }
//#            }
//#        }
//#
//#        switch (this.byUiState) {
//#            case 6:
//#                //"删除提示","您确定要丢弃该物品么"
//#                Tools.drawPopUp(g, this.byPopUpState, Constant.UI_START_X + 4, Constant.UI_START_Y + ((Constant.DRAW_HEIGHT - 90) >> 1), 232, 90, this.imgArray[7], 0x989898, this.imgArray[4], 0, 0, 22, 10, this.imgArray[4], 22, 0, 21, 10, this.sArray[3], this.sArray[4]);
//#                break;
//#
//#        }
        //#endif
    }
    private static int[][] mpack,mpackmenu,mpackdir;
    public void checkTouchEquip(int x, int y) {
    	UiPackage uiPackage = this;
    	switch (uiPackage.byUiState) {
        case 0:
            if (!uiPackage.bKeypressLock) {
                if (!uiPackage.bShowMenu) {
                	if (mpackdir == null) {
                		mpackdir = new int[][]{
                				{135,606,45,30},
                				{135+45,606,45,30},
                		};
                	}
                	int touched = MainCanvas.checkTouch(x, y, mpackdir);
                	if (touched >= 0) {
                		if (touched ==0) {
                			MainCanvas.pressDir(2);
                		} else {
                			MainCanvas.pressDir(3);
                		}
                	}
                	if (mpack == null) {
                		mpack = new int[][]{
	            			{24,143,42,40},
	            			{24+68,143,42,40},
	            			{24+68+68,143,42,40},
	            			{24+68+68+68,143,42,40},
	            			{24+68+68+68+68,143,42,40},
	            			{24,200+5,42,40},
	            			{24+68,200+5,42,40},
	            			{24+68+68,200+5,42,40},
	            			{24+68+68+68,200+5,42,40},
	            			{24+68+68+68+68,200+5,42,40},
	            			{24,310,42,40},
	            			{24+68,310,42,40},
	            			{24+68+68,310,42,40},
	            			{24+68+68+68,310,42,40},
	            			{24+68+68+68+68,310,42,40},
	            			{24,355,42,40},
	            			{24+68,355,42,40},
	            			{24+68+68,355,42,40},
	            			{24+68+68+68,355,42,40},
	            			{24+68+68+68+68,355,42,40},
	            	};
                	}
	            	touched = MainCanvas.checkTouch(x, y, mpack);
	            	if (touched >= 0) {
	            		int off = 1;
	            		touched += off;
	            		int line = touched/5+1;
	            		if (line == uiPackage.bySelectIndex) {//同一行
	            			if (line == 2 || line == 1) {
	                    		if (touched == uiPackage.bySubSelectIndex) {
	                    			 MainCanvas.pressFire();
	                    		} else {
	                    			uiPackage.bySubSelectIndex = (byte) (touched);
	                    			uiPackage.setEquipPos();
//	                    			uiPackage.checkEquipSubSelectIndex(Constant.ITEM_COLUMN_TYPE_EQUIP, (byte) 0, uiPackage.bySelectIndex);
	                    		}
	            			} else if (line ==3 || line == 4){
	            				touched = touched%10;
	            				if (touched == uiPackage.bySubSelectIndex) {
	            					 MainCanvas.pressFire();
	                    		} else {
	                    			uiPackage.bySubSelectIndex = (byte) (touched);
	                    			uiPackage.setEquipPos();
//	                    			uiPackage.checkEquipSubSelectIndex(Constant.ITEM_COLUMN_TYPE_COMMON, (byte) 0, (byte) (uiPackage.bySelectIndex - 2));
	                    		}
	            			} else {//5
	            				if (uiPackage.byCurrentPage > 1) {
	            					uiPackage.byCurrentPage = (byte) (uiPackage.byCurrentPage - 1);
	            					uiPackage.bySubSelectIndex = 1;
	            					uiPackage.setEquipPos();
                                }
	            			}
	            		} else if (line > uiPackage.bySelectIndex) {//向下
	            			uiPackage.bySelectIndex = (byte) line;
	            			uiPackage.byState = (byte) 2;
	            			uiPackage.bKeypressLock = true;
                            //#if NOKIA_S60V5
                             switch (uiPackage.bySelectIndex) {
                                 case 2:
                                	 uiPackage.bySubSelectIndex = (byte) touched;
                                	 uiPackage.iArray = new int[]{1, 1, uiPackage.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 52, 2, 50, 3};
                                     break;
                                 case 3:
                                	 touched = touched%10;
                                	 uiPackage.bySubSelectIndex = (byte) touched;
                                	 uiPackage.iArray = new int[]{1, 1, uiPackage.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 140, 2, 50, 3};
                                     break;
                                 case 4:
                                	 touched = touched%10;
                                	 uiPackage.bySubSelectIndex = (byte) touched;
                                	 uiPackage.iArray = new int[]{1, 1, uiPackage.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 184, 2, 50, 3};
                                     break;
                                 case 5:
                                	 uiPackage.bySubSelectIndex = 1;
                                	 uiPackage.iArray = new int[]{1, 1, Constant.UI_START_Y + Constant.DRAW_HEIGHT - 10, 2, 50, 3};
                                     break;
                             }
                             uiPackage.setEquipPos();
	            		} else {//向上
	            			uiPackage.bySelectIndex = (byte) line;
	            			uiPackage.byState = (byte) 1;
	            			uiPackage.bKeypressLock = true;
                            //#if NOKIA_S60V5
                             switch (uiPackage.bySelectIndex) {
                                 case 1:
                                	 uiPackage.bySubSelectIndex = (byte) touched;
                                	 uiPackage.iArray = new int[]{2, 1, uiPackage.iStartPointY + Constant.FONT_SMALL_HEIGHT + 9, 2, 50, 3};
                                     break;
                                 case 2:
                                	 uiPackage.bySubSelectIndex = (byte) touched;
                                	 uiPackage.iArray = new int[]{2, 1, uiPackage.iStartPointY + Constant.FONT_SMALL_HEIGHT * 2 + 52, 2, 50, 3};
                                     break;
                                 case 3:
                                	 touched = touched%10;
                                	 uiPackage.bySubSelectIndex = (byte) touched;
                                	 uiPackage.iArray = new int[]{2, 1, uiPackage.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 140, 2, 50, 3};
                                     break;
                                 case 4:
                                	 touched = touched%10;
                                	 uiPackage.bySubSelectIndex = (byte) touched;
                                	 uiPackage.iArray = new int[]{2, 1, uiPackage.iStartPointY + Constant.FONT_SMALL_HEIGHT * 3 + 184, 2, 50, 3};
                                     break;
                             }
                             uiPackage.setEquipPos();
	            		}
	            	} else {
	            		 MainCanvas.checkSoftKey();
	            	}
	            	break;
                } else {
//                	if( mpackmenu == null) {
                		 int width = 0;
                	        for (byte i = 0; i < sOpArray.length; i++) {
                	            width = width > sOpArray[i].length() ? width : sOpArray[i].length();
                	        }
                	        width = width * Constant.FONT_CHAR_WIDTH;
                	        //#if NOKIA_S60V5
                	         width = width > 41 ? width + 2 : 43;
                	        //#else
                	//#        width = width > 31 ? width + 2 : 33;
                	        //#endif
                	         mpackmenu = Tools.getPopMenuTouch(sOpArray, (byte) 1, width, Constant.FONT_SMALL_HEIGHT, 0x000000, 0xFFFFFF, 0x00CCFF, bySelectIndex, iStartX - 1, iStartY);
//                	}
                	int touched = MainCanvas.checkTouch(x, y, mpackmenu);
                	if (touched >= 0){
                		if (this.byMenuIndex == touched) {
                			MainCanvas.pressFire();
                		} else {
                			this.byMenuIndex = (byte) touched;
                		}
                	} else {
                		MainCanvas.pressBack();
                	}
                }
            }
        case 6:
        	MainCanvas.checkSoftKey();
    		break;
        }
    }

    /**
     * 清除装备栏资源数据
     */
    public void clearEquip() {
        this.imgArray = null;
        this.packageGoods = null;
        this.taskPackageGoods = null;
        this.iArray = null;
        this.sArray = null;
        this.sOpArray = null;
    }

    /*
     * 根据用户的选择计算当前被选择的物品的索引,在任务的装备界面
     */
    public void checkEquipSubSelectIndex(byte cloumnType, byte direction, byte rows) {
        //最大索引位置
        int max = 0;
        int start = 0;
        int end = 0;
        if (cloumnType == Constant.ITEM_COLUMN_TYPE_EQUIP) {
            max = this.equipPackageGoods.getMaxColumNum();
            //一行开始的位置
            start = (rows - 1) * 5 + 1;
            //一行结束的位置
            end = rows * 5;

        } else if (cloumnType == Constant.ITEM_COLUMN_TYPE_COMMON) {
            max = this.packageGoods.getMaxColumNum();
            //一行开始的位置
            start = (rows - 1) * 5 + 1;
            //一行结束的位置
            end = (this.byCurrentPage - 1) * 10 + rows * 5 > max ? max - (this.byCurrentPage - 1) * 10 : rows * 5;
        }
        if (direction == 0) {
            this.bySubSelectIndex = (byte) (bySubSelectIndex > start ? bySubSelectIndex - 1 : end);
        } else if (direction == 1) {
            this.bySubSelectIndex = (byte) (bySubSelectIndex < end ? bySubSelectIndex + 1 : start);
        }
        this.setEquipPos();
    }

    /**
     * 设置当前装备栏中被选中的物品的位置索引,装备界面
     */
    public void setEquipPos() {
        if (this.bySelectIndex == 1 || this.bySelectIndex == 2) {
            this.shPos = (short) (this.bySubSelectIndex - 1);
            if (this.equipPackageGoods != null && this.equipPackageGoods.checkColumnHasGoods(this.shPos)) {
                this.makeEquipTips(this.equipPackageGoods, this.shPos);
            }
        } else if (this.bySelectIndex == 3 || this.bySelectIndex == 4) {
            this.shPos = (short) ((this.byCurrentPage - 1) * 10 + this.bySubSelectIndex - 1);
            if (this.packageGoods != null && this.packageGoods.checkColumnHasGoods(this.shPos)) {
                this.makeEquipTips(this.packageGoods, this.shPos);
            }
        } else {
            this.shPos = -1;
        }

    }

    /**
     *清除移动特殊的状态和参数
     */
    public void clearSpecialState() {
        if (this.bMoveGoods) {
            this.shMoveIndex = -1;
            this.shMoveDestIndex = -1;
            this.bMoveGoods = false;
            this.shMoveNum = 0;
            this.bShowNumInput = false;
        } else if (this.bUseBindSignItem) {
            this.bUseBindSignItem = false;
        }
    }

    /**
     * 移动物品
     */
    public void moveGoods(short shMoveDestIndex, short num, long key) {
        this.getCurrentPackage().moveGoods(shMoveIndex, shMoveDestIndex, num, key);
        if (this.getCurrentPackage().checkColumn(this.shPos) == 1 && this.getCurrentPackage().getGoodsDesc(this.shPos).length() > 0) {
            //#if NOKIA_S60V5
             this.iGoodsDescHeight = Tools.getParagraphHeight(this.getCurrentPackage().getGoodsDesc(this.shPos), 300, Constant.FONT_SMALL_HEIGHT);
            //#else
//#            this.iGoodsDescHeight = Tools.getParagraphHeight(this.getCurrentPackage().getGoodsDesc(this.shPos), 209, Constant.FONT_SMALL_HEIGHT);
            //#endif
            //#if NOKIA_E72
//#             this.makeItemsTips();
            //#endif
        }
        this.clearSpecialState();
    }

    /**
     * 复制包裹中的物品
     * @param items
     * @param shDestIndex
     */
    public void clonePackageGoods(Goods items, short shDestIndex) {
        items.goodsClone(shDestIndex, this.getCurrentPackage(), this.shPos);
    }

    /**
     * 获得当背包栏中的当前选中的包裹
     * @return
     */
    public Goods getCurrentPackage() {
        switch (this.byTabIndex) {
            case 1:
                return this.packageGoods;
            case 2:
                return this.taskPackageGoods;
            case 3:
                return this.petPackageGoods;
            default:
                return null;
        }
    }

    /**
     * 设置宠物的绑定
     */
    public void petBind(byte stateCode) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        if (this.petPackageGoods.getGoodsBind(this.shPos) == 1) {
            switch (stateCode) {
                case 0:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物解除绑定失败");
                    break;
                case 1:
                    this.petPackageGoods.byBind[this.shPos] = 0;
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物解除绑定成功");
                    break;
                case 2:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "缺少道具“逍遥令”，无法解绑!");
                    break;
            }
        } else {
            switch (stateCode) {
                case 0:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物绑定失败");
                    break;
                case 1:
                    this.petPackageGoods.byBind[this.shPos] = 1;
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "宠物绑定成功");
                    break;
                case 2:
                    MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "缺少道具“誓书”，无法绑定！!");
                    break;
            }
        }
    }

    /**
     * 绑定装备
     * @param stateCode 
     */
    public void bindEquip(byte stateCode) {
        GameBean.b_WAIT_NET_MSG_BACK = false;
        switch (stateCode) {
            case 0:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品绑定失败");
                break;
            case 1:
                this.getCurrentPackage().byBind[this.shPos] = 1;
                switch (this.byRecordTabIndex) {
                    case 1:
                        if (this.packageGoods.getGoodsStackNum(this.shRecordItemIndex) > 1) {
                            this.packageGoods.shStackNum[this.shRecordItemIndex] -= 1;
                        } else {
                            this.packageGoods.deleteGoods(this.shRecordItemIndex);
                        }
                        break;
                    case 2:
                        if (this.taskPackageGoods.getGoodsStackNum(this.shRecordItemIndex) > 1) {
                            this.taskPackageGoods.shStackNum[this.shRecordItemIndex] -= 1;
                        } else {
                            this.taskPackageGoods.deleteGoods(this.shRecordItemIndex);
                        }
                        break;
                    case 3:
                        if (this.petPackageGoods.getGoodsStackNum(this.shRecordItemIndex) > 1) {
                            this.petPackageGoods.shStackNum[this.shRecordItemIndex] -= 1;
                        } else {
                            this.petPackageGoods.deleteGoods(this.shRecordItemIndex);
                        }
                        break;
                }
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品绑定成功");
                break;
            case 2:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的物品不是装备或者武器");
                break;
            case 3:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "您选择的物品已经绑定");
                break;
            case 4:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "此物品已经绑定");
                break;
            default:
                MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "物品绑定出错");
                break;

        }
    }
    
    /////////////////////////
    //
    public static int[][] mPackageTopTouchRect = new int[][]{
    	{20,45,103,30},
    	{128,45,103,30},
    	{235,45,103,30},
    	
    };
    public static int[][] mPackagePageTouchRect = new int[][]{
    	{270,257,35,18},
    	{310,257,35,18},
    	
    };
    public static int[][] mPackageBottomTouchRect = new int[][]{
    	{20,275,100,40},
    	{250,275,100,40},
    	
    };
    
    public static final int BOX_SIZE = 40;
    public static final int START_X = 27;
    public static final int START_Y = 82;
    public static final int SPACE = 4;
    
    private static int[][] mPackageOperateRect;
    public static int[][] mPackageTouchRect = new int[][]{
    	//1
    	{START_X,START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE),START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 2,START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 3,START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 4,START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 5,START_Y,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 6,START_Y,BOX_SIZE,BOX_SIZE},
    	//2
    	{START_X,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE),START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 2,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 3,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 4,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 5,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 6,START_Y + (BOX_SIZE + SPACE),BOX_SIZE,BOX_SIZE},
    	//3
    	{START_X,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE),START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 2,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 3,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 4,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 5,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 6,START_Y + (BOX_SIZE + SPACE) * 2,BOX_SIZE,BOX_SIZE},
    	//4
    	{START_X,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE),START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 2,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 3,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 4,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 5,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	{START_X + (BOX_SIZE + SPACE) * 6,START_Y + (BOX_SIZE + SPACE) * 3,BOX_SIZE,BOX_SIZE},
    	
    	
    	
    };
    
    public void checkTouchPackage(int x, int y)
    {

    	if(bShowMenu)
    	{
	    	mPackageOperateRect = Tools.getPopMenuTouch(sOpArray, (byte) 1,
					Constant.FONT_SMALL.stringWidth("查看") + 2,
					Constant.FONT_SMALL_HEIGHT + 1, 0x000000,
					0xFFFFFF, 0x00CCFF, this.byMenuIndex, iStartX,
					iStartY);
	    	
	    	int touched = MainCanvas.checkTouch(x, y, mPackageOperateRect);
	    	if(touched >= 0)
	    	{
	    		byMenuIndex = (byte) touched;
	    		MainCanvas.pressFire();
	    	}
	    	else
	    	{
//	    		 MainCanvas.checkSoftKey();
	    		MainCanvas.pressBack();
	    	}
    	}
    	else
    	{
    	 int touched = MainCanvas.checkTouch(x, y, mPackageTopTouchRect);
    	 if(touched>=0)
    	 {
    		 bySelectIndex = 1;
			 byTabIndex = (byte) (touched+1);
			 
             if (this.bGetDataFromNet[byTabIndex - 1]) {
                 this.byCurrentPage = 1;
                 this.setBagTotalPage();
                 this.shPos = -1;
             } else {
                 if (this.bShowBAG) {
                     this.showBag(byTabIndex);//通用包裹
                 } else {
                     this.openBag(byTabIndex);//包裹界面
                 }
             }
             
    	 }
    	 else
    	 {
    		 touched = MainCanvas.checkTouch(x, y, mPackagePageTouchRect);
    		 if(touched>=0)
        	 {
    			 
    			 bySelectIndex = 6;
                 
                 if(touched == 0)
                 {
                	 if(byCurrentPage>1)
                	 {
                		 byCurrentPage--;
                		 shPos = -1;
                	 }
                 }
                 else
                 {
                	 if(byCurrentPage < byTotalPage)
                	 {
                		 byCurrentPage++;
                		 shPos = -1;
                	 }
                 }

        	 }
    		 else
    		 {
    			 touched = MainCanvas.checkTouch(x, y, mPackageBottomTouchRect);
        		 if(touched>=0)
            	 {
            		 if(touched == 0)
            		 {
            			 //暂时关闭商城
//            			 MainCanvas.pressNum(4);
            			   MainLogic.getInstance().uiInterFace.sysMessage.showMessage("提示", "该功能还没有开放!");
            			   
            		 }
            		 else
            		 {
            			 MainCanvas.pressNum(6);
            		 }
            	 }
        		 else
        		 {
        			 touched = MainCanvas.checkTouch(x, y, mPackageTouchRect);
            		 if(touched>=0)
                	 {
            			 if (shPos == (byte) (short) (touched + (byCurrentPage - 1) * 28)) {
            				 MainCanvas.pressFire();
            			 } else 
            			 {
	            			bySelectIndex = (byte) (touched/7 + 2);
	            			shPos = (short) (touched + (byCurrentPage - 1) * 28);
							if (this.bySelectIndex < 2 || this.bySelectIndex > 6) {
								this.clearSpecialState();
							}
							this.setGoodsState();
            			 }
                	 }
            		 else
            		 {
            			 MainCanvas.checkSoftKey();
            		 }
        		 }
    		 }
    	 }
    	}
    }
}
